* EXAMPLE FILE FOR PTCDB DATABASE CONNECTION MANAGER CLASS */ /*** DB DETAILS NEEDED FOR THE EXAMPLE TO WORK ***/ $db['user'] = '******'; // 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 */