Welcome Guest, Not a member yet? Register   Sign In
Extends Database Library
#3

(This post was last modified: 04-16-2020, 10:24 AM by emaidana.)

Hello,

After several attempts, the only way it works is extending all the MySQLi driver like kilishan says in his referenced reply. Here I show some code detail of my solution.

I created a folder "MySQLi" inside App/Database, and then created all the files listed (extending the original driver provided):
  • Builder.php
  • Connection.php
  • Forge.php
  • PreparedQuery.php
  • Result.php
  • Utils.php
As example, this is the Builder.php file content:

PHP Code:
<?php namespace App\Database\MySQLi;

use 
CodeIgniter\Database\MySQLi\Builder as BaseBuilder;

/**
* Builder for MySQLi
*/
class Builder extends BaseBuilder
{



Particularly I just needed to customize the "execute" and "query" method in Connection.php file. All the other files stays same as the original one (by extending of course, like Builder.php example), but I must be present at the same folder.

The last step is to point the database driver to the defined in \App\Database\MySQLi.

The file to edit is App/Config/Database.php, it also works with the .env file.

PHP Code:
'DBDriver' => '\App\Database\MySQLi'


Regards.
Reply


Messages In This Thread
Extends Database Library - by emaidana - 03-17-2020, 11:51 AM
RE: Extends Database Library - by MGatner - 03-23-2020, 09:12 AM
RE: Extends Database Library - by emaidana - 04-16-2020, 10:05 AM
RE: Extends Database Library - by sstefanov - 05-08-2023, 05:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB