![]() |
search in two tables - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: search in two tables (/showthread.php?tid=53383) Pages:
1
2
|
search in two tables - El Forum - 07-21-2012 [eluser]anyamanggar[/eluser] hello, i am from indonesia, i have a small problem for search something in database, firs of all, i have one database with two table(info, berita), this is my view Code: <? echo form_open('login/cariinfo'); ?> my controller Code: public function cariinfo(){ model Code: function cariinfo($keyword) { i used that code for search one table its work for seacrh word "title" in table info, but when i want to search in two tables, i have nothing show the result model function cariinfo($keyword) { $this->db->like('title',$keyword); return $this->db->get('info','berita')->result(); } please help, thank you search in two tables - El Forum - 07-21-2012 [eluser]solid9[/eluser] Are you trying to access a join table? Did you used foreign keys? If yes is it InnoDB? search in two tables - El Forum - 07-22-2012 [eluser]anyamanggar[/eluser] [quote author="solid9" date="1342927790"]Are you trying to access a join table? Did you used foreign keys? If yes is it InnoDB? [/quote] yes, i want to access a join table, for foreign keys i dont what this mean search in two tables - El Forum - 07-22-2012 [eluser]skunkbad[/eluser] This is documented @ http://ellislab.com/codeigniter/user-guide/database/active_record.html : Code: $this->db->select('*'); search in two tables - El Forum - 07-22-2012 [eluser]anyamanggar[/eluser] [quote author="skunkbad" date="1343010735"]This is documented @ http://ellislab.com/codeigniter/user-guide/database/active_record.html : Code: $this->db->select('*'); i try your code, the results is didnt show, Code: function cariinfo($keyword) { but if i try like this (search in one table) its work, the result for what i search its show Code: function cariinfo($keyword) { search in two tables - El Forum - 07-22-2012 [eluser]anyamanggar[/eluser] if i used return like this Code: function cariinfo($keyword) { erorr like this Code: A PHP Error was encountered search in two tables - El Forum - 07-22-2012 [eluser]anyamanggar[/eluser] what i miss ? please help me thank you .. search in two tables - El Forum - 07-22-2012 [eluser]anyamanggar[/eluser] i have been update my code to like this Code: function cariinfo($keyword) { stil didnt show the data what i search.. search in two tables - El Forum - 07-22-2012 [eluser]skunkbad[/eluser] You're going to need to post the structure of your tables. The proposed code was just an example, as I know nothing about your database. search in two tables - El Forum - 07-22-2012 [eluser]anyamanggar[/eluser] [quote author="skunkbad" date="1343017364"]You're going to need to post the structure of your tables. The proposed code was just an example, as I know nothing about your database.[/quote] this my database, i have been attach files for this post, http://ollatois.com/files/tnt.sql |