Welcome Guest, Not a member yet? Register   Sign In
why is the $this->db not available in a certain module?
#7

(This post was last modified: 04-24-2021, 07:09 AM by wdeda.)

I believe there is a function deviation. The code is self-explanatory: it must be used to connect to a database. Unlike $db = $this->db; which can only be used in Controllers/Models, since "$this->" cannot be used in a non-object context.
Although not recommended if you want to make a query outside the Model/Controller you can use it:
PHP Code:
$db db_connect();
$query $db->table('mytable')
// and so on ... 


https://codeigniter.com/user_guide/datab...cting.html

I insist: I'm talking about CodeIgniter 4!
This option, db_connect();, is exclusive to CI4.

https://codeigniter.com/userguide3/datab...cting.html
Reply


Messages In This Thread
RE: why is the $this->db not available in a certain module? - by wdeda - 04-24-2021, 06:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB