Is this right -Select, Joins, Where in Codeigniter? |
[eluser]brucebat[/eluser]
Hi all, I have been building my first join in codeigniter however I don't think I have done it correctly as the variable dump of the result query is giving me this: Quote:object(CI_DB_mysql_result)#22 (8) { ["conn_id"]=> resource(30) of type (mysql link persistent) ["result_id"]=> resource(40) of type (mysql result) ["result_array"]=> array(0) { } ["result_object"]=> array(0) { } ["custom_result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows"]=> int(0) ["row_data"]=> NULL } Should it not be giving me an array of values from my tables I have selected and joined? Here is my model code with a var_dump purely in there just to test my code. Code: public function view_record($record_id) Here is my Schema http://i.imgur.com/Dju0G.png Thanks for your time. I was following the example in User Guide
[eluser]brucebat[/eluser]
Okay update: I added the following code: Code: if ($returned_record->num_rows() > 0) Just for testing and I am not getting "No record"
[eluser]brucebat[/eluser]
Solved Turns out it is better to use Left joins for rows that may not have foreign keys!
[eluser]Aken[/eluser]
You also need to use some form of $result->result() to retrieve records. var_dump($result) acts as it should. |
Welcome Guest, Not a member yet? Register Sign In |