get DB handler in CodeIgniter for stand-alone Libraries

We were working on a project where some developers were working with CI and were developing libraries there, and some developers were developing stand-alone libraries. But both groups were working on the same project.
At some point we needed all those stand-alone libraries to be used in CI as well.
For common code it’s not a big deal, the only problem which took a little bit of time to figure out was using the DataBase. We didin’t want to make new DB connections, so how could we use the current connection, inside an stand-alone code.
The answer is pretty easy, CI’s DB class has a non-documented attribute which returns back the DB handler.
or if you have multiple DB cnnections that would be :
$this->dbw->conn_id;
and then you can easily pass the DB connection to regular mysql_query function like this :
and as an example :
CodeIgniter, General, MySQL
Written by: MajiD Fatemian
Run into a similar issue when utilizing database handlers/connections.
I haven’t tested it yet but assume $this->dbr->conn_id is actual db resource and not CI object?
Following CI Log: “Bugfixes for 1.6.1 - Fixed a bug (#3404) where the MySQLi driver was testing if $this->conn_id was a resource instead of an object.” which is a bit confusing.
Thanks
Rad
@Rad
Yeah $this->dbr->conn_id is the actual DB resource and not a CI object, that’s why you can use it in a mysql_query function directly.