My join is not working |
I have a search field in my form which searches data from a database and displays it on a result page. When I try to search data I get this error.
Quote:A PHP Error was encountered I know the data I am passing to the view does not contain the 'names' field which means the query I am using is not retrieving this value from the database. Here is my database query Code: //this function gets all the contacts given a cerain parameter The 'names' field is in my office table, thus it must be my join function which is not working. Any help will be greatly appreciated
$this->db->join('offices', 'offices.id = phones.offices', 'left');
Website: http://avenir.ro
Your query won't return the field 'names' because you aren't requesting it: "$this->db->select('users,numbers');".
At least tell us the structure of the tables you're trying to join, in any case a LEFT JOIN will bring you everything from the "left" table and NULL if no coincidence in "joined" table.
I have three tables the phones table which has these fields(users, numbers, offices and id). The offices field is a foreign key which references the id field in the offices table. The offices table has these fields(names, id and departments). The departments field in the office table is a foreign key which references the id field in the departments table. The departments table has these fields(names, id). I want the query to return the results if the user enters a department or an office or a phone number
You haven't select your office.names, try this :
PHP Code: $this->db->select('phones.users, phones.numbers'); |
Welcome Guest, Not a member yet? Register Sign In |