Welcome Guest, Not a member yet? Register   Sign In
models in CI4 - OK to put in app/Models? What about naming/namespacing/autoloading?
#3

(This post was last modified: 12-11-2020, 02:08 PM by sneakyimp.)

(12-11-2020, 12:50 PM)InsiteFX Wrote: You can still create your own models without using CodeIgniter's Model.
EDIT: like many of your other responses, this one is not especially informative. I was rather hoping that someone might read my entire post and comment with something a bit less terse and more in the spirit of discussion.

I would also point out that the documentation I linked in my original post makes it clear that one need not extend CodeIgniter\Model:
Quote:You do not need to extend any special class to create a model for your application. All you need is to get an instance of the database connection and you’re good to go. This allows you to bypass the features CodeIgniter’s Model gives you out of the box, and create a fully custom experience.
PHP Code:
<?php namespace App\Models;

use 
CodeIgniter\Database\ConnectionInterface;

class 
UserModel
{
    protected 
$db;

    public function 
__construct(ConnectionInterface &$db)
    {
        
$this->db =& $db;
    }

Reply


Messages In This Thread
RE: models in CI4 - OK to put in app/Models? What about naming/namespacing/autoloading? - by sneakyimp - 12-11-2020, 01:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB