This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation

Database Connectivity

Database Library

concrete5 uses the ADODB Database Library link to connect to its database.

Accessing the Database Object

Developers can access the database object (and perform any ADODB-specific functions to it) from within any functions or classes simply by running the following command:

$db = Loader::db();


The $db object returned in the above is an ADODB database object. It supports all ADODB library commands.

A few additional database methods are available from a generic concrete5 Database wrapper class. The following methods can be called statically on that class:


Returns an ADOSchema object for use with the ADODB Data Dictionary functionality (link to the relevant ADODB data dictionary documentation.) 


If $debug is set to true, all database queries will be displayed within the page. If set to false, they will no longer be displayed.


If $logging is set to true, all database queries will be logged into the adodb_logsql table in your server's database.

Connecting to Other Databases

Developers are able to switch active database throughout a session with a simple command

// This query runs on the original concrete5 database 	$db = Loader::db(); 	$db->Execute('select * from TestTable'); 	 // Load another database for some reason 	$db = Loader::db( 'newserver', 'newuser', 'newpassword', 'newdatabase', true);			 	$db->Execute('select * from TestTable2'); 	 // return to the original db session 	$db = Loader::db(null, null, null, null, true);  
Loading Conversation