Problems with ActiveRecord: where($array) |
[eluser]Benedikt[/eluser]
Hi, I use ActiveRecord for querying my databases. I implemented my own function to check if a row exists in the database already. Basically it works when I pass just one parameter as "where": Code: $query = $this->db->select($col)->from($tbl)->where($val)->get(); My array $var looks like this: Code: $var = array ( I checked if the array passed to the function is filled and it is. Is this a bug in 1.6.3 or am I hving a mistake? Thanks for your help, Ben.
[eluser]zimco[/eluser]
You might want to look at the user's manual for get_where Code: $query = $this->db->get_where('mytable', array('id' => $id), $limit, $offset); It will do a much better job of explaining than i ever could, and i'm a bit of a newbie myself and don't want to send you on a wild goose-chase through your code.
[eluser]Michael Wales[/eluser]
Code: if_exists($params = array()) {
[eluser]Benedikt[/eluser]
Ok, I see. Thank you for your help. But there is one paragraph which confuses me (I followed this paragraph): "Associative array method: $array = array('name' => $name, 'title' => $title, 'status' => $status); $this->db->where($array); // Produces: WHERE name = 'Joe' AND title = 'boss' AND status = 'active'" Is this just not working in chaining or not working in general? EDIT: Seems Im using it wrong: Code: $query = $this->db->select('id')->get_where('mytable', $var, 1, 0);
[eluser]Benedikt[/eluser]
Ok, got it to work like that: Code: $query = $this->db->select($col)->from($tbl)->get_where($tbl, $val, 1, 0); |
Welcome Guest, Not a member yet? Register Sign In |