No like in getResultArray |
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!
(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(); (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] =>
Where what was the print_r(...); statement inserted?
It looks as though the connection to the database failed. (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
08-09-2018, 08:40 AM
(This post was last modified: 08-09-2018, 09:40 AM by John_Betong. Edit Reason: Mentioned missing images )
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 (08-09-2018, 08:40 AM)John_Betong Wrote: Try this because it works for me:
08-10-2018, 12:26 AM
(This post was last modified: 08-10-2018, 12:54 AM by puschie. Edit Reason: added code )
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/d...cting-data public function searchPart($data) { return $this->db->table('par')->like('title', $data)->get(); } |
Welcome Guest, Not a member yet? Register Sign In |