What could be causing the database retrieval error? - 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: What could be causing the database retrieval error? (/showthread.php?tid=87651) |
What could be causing the database retrieval error? - RohanxSiriya - 05-15-2023 I'm using CodeIgniter 4, and I encountered an error (Call to a member function table() on null) when trying to retrieve records from the database using the following code: $CI = & get_instance(); $CI->db->select('*'); $CI->db->from($table_name). I then referred to the documentation and tried using the $db->table("tablename") method, but it also failed. RE: What could be causing the database retrieval error? - Mni.day - 05-15-2023 PHP Code: $db = db_connect(); RE: What could be causing the database retrieval error? - kilishan - 05-15-2023 What version of CodeIgniter are you using @RohanxSiriya ? RE: What could be causing the database retrieval error? - InsiteFX - 05-15-2023 He say's he is use CodeIgniter 4. You can not use that code with CodeIgniter 4, that's CodeIgniter 3 code. RE: What could be causing the database retrieval error? - kilishan - 05-16-2023 Ah, I missed the version reference, I guess, when I saw the mix of 3 and 4 code I just wanted to make sure. In that case @Mni.day has the right code, though there's more variables than necessary needed. |