pclib  2.3.2
Lightweight PHP framework
Examples of using database functions parameters

Db->select*() functions:

$arr = $db->select('PERSONS', 'ID=1'); //select * from PERSONS where ID='1' limit 1
$arr = $db->select('PERSONS', pri(1)); //uses pri() helper - do the same as before
$arr = $db->select('PERSONS:NAME,SURNAME', 'ID=1'); //select NAME,SURNAME from PERSONS where ID='1' limit 1
$arr = $db->select('select * from PERSONS where ID=1');

Db->select*() functions with parameters:

$param = array ('A' => 'test', 'B' => 4);
$arr = $db->select("select * from PERSONS where A='{A}' and B={B}", $param);
$arr = $db->select('PERSONS', "A='{A}' and B={B}", $param);
$param_index = array ('test', 4);
$arr = $db->select("select * from PERSONS where A='{0}' and B={1}", $param_index);
$arr = $db->select('PERSONS', "A='{0}' and B={1}", $param_index);
//without array
$arr = $db->select("select * from PERSONS where A='{0}' and B={1}", 'test', 4);
$arr = $db->select('PERSONS', "A='{0}' and B={1}", 'test', 4);

Db->insert():

$data = array ('NAME' => 'John', 'SURNAME' => 'Rambo');
$person_id = $db->insert('PERSONS', $data);

Db->update():

$data = array ('NAME' => 'John', 'SURNAME' => 'Rambo');
$db->update('PERSONS', $data, "ID='4'"); //update PERSONS set NAME='John',SURNAME='Rambo' where ID='4'
$db->update('PERSONS', $data, "ID='{0}'", 4);
$db->update('PERSONS', 'MONEY=MONEY+1000', "ID='4'"); //update PERSONS set MONEY=MONEY+1000 where ID='4'