CodeIgniter Forums
How to load DB_froge class inside my own driver? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: How to load DB_froge class inside my own driver? (/showthread.php?tid=62971)



How to load DB_froge class inside my own driver? - webdevron - 09-13-2015

Hello there. I've my own driver called data_driver.php and using this drriver, I want to create some database tables. Whenever I'm going to load db_forge class into my driver there is an error saying:

Invalid driver requested: Data_driver_dbforge

I think the load request treating db_forge as a child driver. So what to do now? Looking forword to your answer.
Thanks in advance.


RE: How to load DB_froge class inside my own driver? - mwhitney - 09-14-2015

I'm assuming data_driver is a database driver. In most cases, when building a new database driver I would recommend looking at the MySQLi driver as a reference. Each driver is structured as a directory with the base driver name, followed by a series of files to support the various portions of the database library/libraries, so the file/directory structure looks something like this:
/system/database/drivers/{driver_name}/
{driver_name}_driver.php
{driver_name}_forge.php
{driver_name}_result.php
{driver_name}_utility.php

It gets a little more complicated for drivers like PDO, which have their own subdrivers.

When you load DB_forge, it gets the driver information from the database library, then loads a file from /system/database/drivers/{driver_name}/{driver_name}_forge.php to tell it how DB_forge is going to interact with the underlying database. If this file doesn't exist, you can't use DB_forge for the current driver.