What could be causing the database retrieval error? |
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. PHP Code: $db = db_connect();
What version of CodeIgniter are you using @
He say's he is use CodeIgniter 4.
You can not use that code with CodeIgniter 4, that's CodeIgniter 3 code. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
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. |
Welcome Guest, Not a member yet? Register Sign In |