CI3 num_rows on CI4 - 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: CI3 num_rows on CI4 (/showthread.php?tid=81611) Pages:
1
2
|
CI3 num_rows on CI4 - serialkiller - 03-26-2022 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 RE: CI3 num_rows on CI4 - demyr - 03-26-2022 Try this: PHP Code: public function number_of_something($something_id){ RE: CI3 num_rows on CI4 - GGitzOle - 03-26-2022 If there is only one row expected, just do: PHP Code: $row = $this->db->table('table')->select('fileds')->where('id', 123)->get()->getRow(); RE: CI3 num_rows on CI4 - InsiteFX - 03-27-2022 It has changed. PHP Code: $query = $db->query('SELECT * FROM my_table'); RE: CI3 num_rows on CI4 - serialkiller - 03-29-2022 (03-27-2022, 12:05 AM)InsiteFX Wrote: It has changed. I tried that too, but VS Code keeps reporting it to me as an error RE: CI3 num_rows on CI4 - wdeda - 03-29-2022 PHP Code: $db = $this->db; // inside a model RE: CI3 num_rows on CI4 - serialkiller - 03-29-2022 (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 RE: CI3 num_rows on CI4 - ignitedcms - 03-29-2022 What do you mean by VS Code parser? Are you using an extension that hooks into CI4? RE: CI3 num_rows on CI4 - InsiteFX - 03-30-2022 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'); RE: CI3 num_rows on CI4 - serialkiller - 03-30-2022 (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 |