// mysql user $db['pass'] = '******'; // mysql pass $db['database'] = 'database name'; // mysql database name /*************************************************************/ require_once '../PtcDb.php'; // including the PtcDb class /* ADDING A CONNECTION, THIS WILL BE THE DEFAULT CONNECTION */ PtcDb::add(array('user' => $db['user'], 'pass' => $db['pass'], 'db' => $db['database'])); /* GETTING THE CONNECTION DETAILS */ $conn_details = PtcDb::getConnection('default'); // gets all connections if name param is not specified var_dump($conn_details); /* GETTING THE PDO OBJECT */ $pdo_object = PtcDb::getPdo('default'); /* USING PDO TO EXECUTE QUERIES WITH THE DEFAULT CONNECTION */ $query = PtcDb::prepare('SELECT * FROM some table'); // same as $pdo_object->prepare( ); //$query->execute( ); //var_dump( $query->fetchAll( ) ); /* * THE FOLLOWING LINES REQUIRE THE PTCQUERYBUILDER.PHP FILE * COMMENT LINE 45 TO EXECUTE THE REST OF THE CODE */ die; /* ADDING ANOTHER DATABASE CONNECTION WITH THE QUERY BUILDER CLASS SUPPORT */ require_once '../PtcQueryBuilder.php'; // including the Query Builder class PtcDb::add(array('user' => $db['user'], 'pass' => $db['pass'], 'db' => $db['database'], 'query_builder' => true, 'pdo_attributes' => array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC)), 'new connection'); /* GETTING THE QUERY BUILDER OBJECT */