Welcome Guest, Not a member yet? Register   Sign In
Migrating CI3 to CI4, need query->numRows function
#11

(This post was last modified: 01-25-2021, 07:02 AM by MGatner.)

For the record a simple way to extend the Database classes is to create your own driver, which can extend any current driver with whatever modifications you need. For example you could create app/Database/MyDriver/Connection.php with:
PHP Code:
class Connection extends \CodeIgniter\Database\MySQLi\Connection

and then use it in app/Config/Database.php (or .env):
PHP Code:
    /**
     * The default database connection.
     *
     * @var array
     */
    
public $default = [
...
        
'DBDriver' => 'App\Database\MyDriver',
...
    ]; 


Your driver needs to support every class (see the list here https://github.com/codeigniter4/CodeIgni...ase/MySQLi) but they can be empty class extensions or even just class aliases. You can see my class alias approach for my WordPress database driver, which is a simple extension of the core MySQLi:
https://github.com/tattersoftware/codeig...ection.php
Reply


Messages In This Thread
RE: Migrating CI3 to CI4, need query->numRows function - by MGatner - 01-25-2021, 07:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB