search in two tables |
[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
[eluser]solid9[/eluser]
Are you trying to access a join table? Did you used foreign keys? If yes is it InnoDB?
[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
[eluser]skunkbad[/eluser]
This is documented @ http://ellislab.com/codeigniter/user-gui...ecord.html : Code: $this->db->select('*');
[eluser]anyamanggar[/eluser]
[quote author="skunkbad" date="1343010735"]This is documented @ http://ellislab.com/codeigniter/user-gui...ecord.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) {
[eluser]anyamanggar[/eluser]
if i used return like this Code: function cariinfo($keyword) { erorr like this Code: A PHP Error was encountered
[eluser]anyamanggar[/eluser]
i have been update my code to like this Code: function cariinfo($keyword) { stil didnt show the data what i search..
[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.
[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 |
Welcome Guest, Not a member yet? Register Sign In |