pclib  3.0.0
Lightweight PHP framework
Examples of using database functions parameters

Db->select*() functions:

$arr = $db->select('select * from PERSONS where ID=1'); //with complete SQL
$arr = $db->select('PERSONS', 'ID=1'); //select * from PERSONS where ID='1' limit 1
$arr = $db->select('PERSONS', ['ID' => 1]); //same as before - you can use array for filtering
$arr = $db->select('PERSONS:NAME,SURNAME', ['ID' => 1]); //select NAME,SURNAME from PERSONS where ID='1' limit 1

Db->select*() functions with parameters:

$param = ['A' => 'test', 'B' => 4];
$arr = $db->select("select * from PERSONS where A='{A}' and B='{B}'", $param);
$arr = $db->select('PERSONS', ['A'=> 'test', 'B' => 4]); //same as before
//using array with numeric indexes
$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]);
//without array
$arr = $db->select("select * from PERSONS where A='{0}' and B={1}", 'test', 4);
//IN clausule: Array will be converted into list suitable for IN () clausule
$arr = $db->select("select * from PERSONS where CATEGORY in ('{LIST_OF_IDS}')", ['LIST_OF_IDS' => [1,2]]);

You can use hash mark in parameter to force integer conversion: {#A} - will be always integer.

Db->insert(), Db->delete():

$new_id = $db->insert('PERSONS', ['NAME' => 'John', 'SURNAME' => 'Rambo']);
$db->delete('PERSONS', ['ID' => $new_id]);

Db->update():

$data = ['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', $data, ['ID' => 4]);
$db->update('PERSONS', 'MONEY=MONEY+1000', "ID='4'"); //update PERSONS set MONEY=MONEY+1000 where ID='4'