No like in getResultArray - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: No like in getResultArray (/showthread.php?tid=71386) |
No like in getResultArray - Nome - 08-08-2018 Hello, I previously used query builder $db->query("MY_QUERY"); Now decided to try the patterns method $builder->like(), in which I get something wrong... The error concerns the output function, but why? Call to undefined method CodeIgniter\Database\MySQLi\Builder::getResultArray() Controller PHP Code: $model = new \Modules\Par\Models\ParModel(); Model PHP Code: public function searchPart($data) { View PHP Code: foreach ($query->getResultArray() as $row) Thanks! RE: No like in getResultArray - John_Betong - 08-08-2018 (08-08-2018, 02:00 PM)Nome Wrote: Hello, I previously used query builder $db->query("MY_QUERY"); I would first start with the Class and check the return values to ensure that the script returns exactly what you expect then continue to the next variable: PHP Code: $model = new \Modules\Par\Models\ParModel(); RE: No like in getResultArray - Nome - 08-09-2018 (08-08-2018, 11:18 PM)John_Betong Wrote: I would first start with the Class and check the return values to ensure that the script returns exactly what you expect then continue to the next variable: This only added questions). Why is my request written in the manual triggered and this one is not? After all, the requested data exists, there is a table `par` and a column `title`... Should an empty response cause an error? Code: [lastQuery:protected] => RE: No like in getResultArray - John_Betong - 08-09-2018 Where what was the print_r(...); statement inserted? It looks as though the connection to the database failed. RE: No like in getResultArray - Nome - 08-09-2018 (08-09-2018, 02:09 AM)John_Betong Wrote: Where what was the print_r(...); statement inserted? Oh sure... Code: Modules\Parts\Models\PartsModel Object RE: No like in getResultArray - John_Betong - 08-09-2018 Try this because it works for me: PHP Code: $db = \Config\Database::connect(); // list of jokes https://johns-jokes.cf/home?app=4 // select any joke title from above // images have yet to be displayed because URLs in database and link to another domain RE: No like in getResultArray - Nome - 08-09-2018 (08-09-2018, 08:40 AM)John_Betong Wrote: Try this because it works for me: RE: No like in getResultArray - John_Betong - 08-09-2018 @Nome >>> Search on the request works, I wrote about this in the beginning. >>> I'm curious how to do this through $builder->like()... I tried without success and think maybe $builder->like() has not been implemented yet. Perhaps @kilishan or another user could suggest a solution. RE: No like in getResultArray - puschie - 08-10-2018 the like function return a $this, and the builder class does not have the getResultArray functions. you need to execute the query first ( you have no action applied, so ci use select as default. to execute your builder ->get() ) https://bcit-ci.github.io/CodeIgniter4/database/query_builder.html#selecting-data public function searchPart($data) { return $this->db->table('par')->like('title', $data)->get(); } |