示例#1
0
 */
function PA($array)
{
    echo '<pre>', print_r($array, true), '</pre>';
}
// include pdo class wrapper
include_once 'class.pdowrapper.php';
// create new object of class wrapper
$p = new PdoWrapper();
echo "// select with fields and one where condition #1";
// set fields for table
$selectFields = array('customerNumber', 'customerName', 'contactLastName', 'contactFirstName', 'phone');
// set where condition
$whereConditions = array('customerNumber' => 103);
// select with where and bind param use select method
$q = $p->select('customers', $selectFields, $whereConditions)->traceEnable()->results();
// print array result
PA($q);
echo "// select with fields and two where condition #2";
// set fields for table
$selectFields = array('customerNumber', 'customerName', 'contactLastName', 'contactFirstName', 'phone');
// set where condition
$whereConditions = array('customerNumber' => 103, 'contactLastName' => 'Schmitt');
// select with where and bind param use select method
$q = $p->select('customers', $selectFields, $whereConditions)->traceEnable()->results();
// print array result
PA($q);
echo "// select with fields and LIMIT clause condition #3";
// set fields for table
$selectFields = array('customerNumber', 'customerName', 'contactLastName', 'contactFirstName', 'phone');
// set where condition
示例#2
0
// include pdo class wrapper
include_once '../class/class.pdowrapper.php';
// database connection setings
$dbConfig = array("host" => "localhost", "dbname" => 'sampledb', "username" => 'root', "password" => '');
// get instance of PDO Wrapper object
$db = new PdoWrapper($dbConfig);
// get instance of PDO Helper object
$helper = new PDOHelper();
// set error log mode true to show error on screen or false to log in log file
$db->setErrorLog(true);
// Example -1
$selectFields = array('customerNumber', 'customerName', 'contactLastName', 'contactFirstName', 'phone');
// set where condition
$whereConditions = array('customerNumber' => 103);
// select with where and bind param use select method
$q = $db->select('customers', $selectFields, $whereConditions)->showQuery()->results();
// print array result
PDOHelper::PA($q);
// Example -2
$whereConditions = array('lastname =' => 'bow', 'or jobtitle =' => 'Sales Rep', 'and isactive =' => 1, 'and officecode =' => 1);
$data = $db->select('employees', array('employeenumber', 'lastname', 'jobtitle'), $whereConditions)->showQuery()->results();
// print array result
PDOHelper::PA($q);
// Example -3
$whereConditions = array('lastname =' => 'bow', 'or jobtitle =' => 'Sales Rep', 'and isactive =' => 1, 'and officecode =' => 1);
// select with where and bind param use select method
$q = $db->select('employees', array('employeeNumber', 'lastName', 'firstName'), $whereConditions)->showQuery()->results();
// print array result
PDOHelper::PA($q);
// Example -4
$selectFields = array('customerNumber', 'customerName', 'contactLastName', 'contactFirstName', 'phone');
示例#3
0
 public function databaseTest()
 {
     $db = new PdoWrapper();
     $result = $db->select("test")->results();
     pad($result);
 }