mercredi 6 juillet 2016

passing multiple arguments to sql query in code igniter without using active records

I have already researched on this but didnt come to get the correct answer, I am trying to pass multiple arguments to an sql query in code igniter without using active records and its not working for me, see what I have done below

in my model I have:

function get_values($id, $age)
{
$sql='SELECT * FROM tblRegister where id=? AND unit=?';
$query=$this->db->query($sql, array('$id','$age'));
return $query->result_array();

}

in the controller I have:

function get_values()
{
$result=$this->register_model->get_values(32, 23);

}

this doesnt work for me, i think its an error with passing the arguments to the query, how to I format the syntax so that it works just fine? Regards

Aucun commentaire:

Enregistrer un commentaire