Datebase - page7/pt GitHub Wiki
use pt\framework\db as db;
$db = db::init();
// or
$db = \pt\framework\db::init();
$newconfig = array(
'dsn' => 'mysql:dbname=demo;host=localhost:3306',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
);
$db = db::init($newconfig);
$row = $db -> prepare("SELECT * FROM `table` WHERE `id`=:id")
-> execute(array(':id'=>1));
If it's a select query, will return the selected rows;
A Update/Delete query, will return effect rows number;
A Insert query, will return last_insert_id or effect rows number;
$row2 = $db -> execute(array(':id'=>2));
- dns : pdo's DSN to connect to the database
- username
- password
- charset : default "utf8"