Welcome Guest, Not a member yet? Register   Sign In
How to write query on Model and Call Model using Controller in Codeigniter 4?
#2

You don't need to write the SQL query. Use findAll like this:
PHP Code:
public function all()
{
    return $this->asArray()->findAll();



See the this example: https://codeigniter4.github.io/userguide...your-model

Like in CI3, you can return the data as an object or as an array. In CI4 use asArray or asObject:
https://codeigniter4.github.io/userguide...pe-changes
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply


Messages In This Thread
RE: How to write query on Model and Call Model using Controller in Codeigniter 4? - by includebeer - 09-29-2019, 07:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB