I'm looking for a way to access the database object CakePHP uses to make its calls to the database.
I have a class I wrote outside of CakePHP that uses the database. Instead of opening its own connection, I thought it would be nice to just use one that may already be open.
I have CakePHP set up to use MySQLi and the class I built uses MySQLi as well.
you can use DboSource Class for accessing Database and making database calls.
DboSource Class API doc
getConnection
$db= &ConnectionManager::getDataSource('datasourceName'); // as defined in DATABASE.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.