<?php
/*
This is only an example script, this must be adapted to your connection params, and use an existing database with existing tables.
*/
include('DBO.php');
$pdoConfig = new stdClass();
$pdoConfig->_database = isset($dbname) ? $dbname : '';
$pdoConfig->_server = isset($servername) ? $servername : '';
$pdoConfig->_user = isset($dbusername) ? $dbusername : '';
$pdoConfig->_password = isset($dbpassword) ? $dbpassword : '';
$pdoConfig->_engine = 'mysql';
$pdoConfig->_showErrors = true;
$DBO = new DBO($pdoConfig);
//Using table prefix
define('TABLE_PREFIX', 'mydb_');
$query = $DBO->query(
"SELECT * FROM {my_table} WHERE id = ? ORDER BY order ASC ", 1
);
var_dump($query);
// With param types '%d' = int, '%s' = string, '%b' = boolean
$query1 = $DBO->query(
"SELECT * FROM my_table WHERE id = '%d' ORDER BY order ASC ", 1
);
var_dump($query1);
// Only the first record
$query2 = $DBO->queryFirst(
"SELECT * FROM my_table WHERE parentId = '%d' ORDER BY order ASC ", 1
);
var_dump($query2);
|