Welcome Guest, Not a member yet? Register   Sign In
CI_DB_driver never constructed
#1

[eluser]Heatherita[/eluser]
Hi. I'm running CodeIgniter with gentoo r8, php 5.2.6, Apache2.

I think I have a handle on how the database array is being initialized.

The database driver (CI_DB_odbc_driver in my case) extends CI_DB. In my case CI_DB is
the instance of CI_DB_driver that is dynamically created around line 100 of DB.php with this:

eval('class CI_DB extends CI_DB_driver { }');



somewhere around line 120 of DB.php,this driver is constructed.
$DB =& new $driver($params);

Since CI_DB_ODBC_driver is a subclass of CI_DB_driver, I would expect CI_DB_driver to be constructed at this point.

However, only CI_DB_ODBC_driver is constructed. CI_DB_driver is not constructed!

Therefore, $params are never passed, variables are never set and the DB connection cannot be made because there are no connection parameters.

To workaround this, I simply changed CI_DB_ODBC_driver constructor to do what CI_DB_driver's constructor should do, from this:


function CI_DB_odbc_driver()
{
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
}


to this:

function CI_DB_odbc_driver($params)
{
print("Constructing CI_DB_odbc_driver. <BR>");

$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
if (is_array($params))
{
foreach ($params as $key => $val)
{
$this->$key = $val;
print("key is " . $key . " value is " . $val . "<br>");
}
}

log_message('debug', 'ODBC Driver Class Initialized');
}


Now the driver class is initialized and the database connection is made.

If anyone knows how I can make CI_DB_driver's constructor work as expected, I'd love to hear about it.

Thanks,

Heather Buch
#2

[eluser]Heatherita[/eluser]
Looks like my answer is here (post #3)

http://ellislab.com/forums/viewreply/351821/

Thanks!

Heather




Theme © iAndrew 2016 - Forum software by © MyBB