Location: PHPKode > scripts > classpgDB > classpgdb/example.php
 * This is just very brief example, for complete documentation see wikipages at 
 * http://www.graphinet.sk/wiki/index.php/PgDB_-_Database_Access_Wraper_for_Postgres 
$db = new pgDB('localhost', 'postgres', 'Sc82Ut90', 'test_db');


//create table
CREATE TABLE test_table
  id serial NOT NULL,
  name varchar(50) NOT NULL,
  surname varchar(50) NOT NULL
ALTER TABLE test_table OWNER TO postgres;

//locking query types

//locking table fields

//insert data
$table = 'test_table';
$fields = array('name', 'surname');
$data = array('name'=>'whatever', 'surname'=>'something');

$db->InsertObject($table, $fields, $data);

$data[0] = array('name'=>'whatever2', 'surname'=>'something2');
$data[1] = array('name'=>'whatever3', 'surname'=>'something3');

$db->InsertObject($table, $fields, $data);

//update data
$table = 'test_table';
$fields = array('surname', 'name');
$data = array('surname'=>'new_surname', 'name'=>'new_name');

$db->UpdateObject('id = 3', $table, $fields, $data);

//deleting rows with use of helper functions to build SQL statement in where clause
$db->DeleteObject('id'.$db->IN('1,5'), 'test_table');
$db->DeleteObject('id'.$db->NOT_IN(array(2,3)), 'test_table');

//select data
$select_data = $db->GetResults("SELECT * FROM test_table WHERE 1 = 1");

Return current item: classpgDB