CI3 num_rows on CI4 |
In CI3 I did this
PHP Code: $query = $this->db->select('fileds')->where('id', 123)->get('table'); In CI4, on the other hand, I tried these ways PHP Code: $query = $this->db->table('table')->select('fileds')->where('id', 123)->get(); or PHP Code: $this->doesExist = $query->countAll(); or PHP Code: $this->doesExist = $query->getNumRows(); The query gets the data, but getting the number of rows doesn't work in any way
Try this:
PHP Code: public function number_of_something($something_id){
If there is only one row expected, just do:
PHP Code: $row = $this->db->table('table')->select('fileds')->where('id', 123)->get()->getRow();
It has changed.
PHP Code: $query = $db->query('SELECT * FROM my_table'); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(03-29-2022, 06:09 AM)wdeda Wrote: It is not a query problem, the quest is performed correctly, I just want to know / understand which of the methods I listed at the beginning I have to use instead of the old num_rows, because whatever I put is marked as an error by the VS Code parser, which does not happen with any other function linked to the DB
What do you mean by VS Code parser? Are you using an extension that hooks into CI4?
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
If it doe's not work then you must be using a different version of CodeIgniter 4
system/Database/BaseResult.php it's there in CodeIgniter 4.1.9 PHP Code: $query = $db->query('SELECT * FROM my_table'); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(03-29-2022, 09:57 AM)ignitedcms Wrote: What do you mean by VS Code parser? Are you using an extension that hooks into CI4? I use extensions, but only one related to php which until now has always reported non-existent functions that's why I don't understand (03-30-2022, 12:03 AM)InsiteFX Wrote: If it doe's not work then you must be using a different version of CodeIgniter 4 Yes, in fact I searched and found myself too, at this point the problem must be on the sequence of the code, probably in this way it is not recognized as an executable or something like that, I will post the relae code |
Welcome Guest, Not a member yet? Register Sign In |