PHP code example of catsand / pdo-database-wrapper

1. Go to this page and download the library: Download catsand/pdo-database-wrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

catsand / pdo-database-wrapper example snippets


public query($sql, ...value)

public select($sql, ...value)

public selectCell($sql, ...value);
public column($sql, ...value);
public cell($sql, ...value);

public selectRow($sql, ...value);
public fetch($sql, ...value);
public row($sql, ...value);

public selectArray($sql, ...value);

public selectHash($sql, ...value);
public hash($sql, ...value);

public insert($tableName, $valueArray, $columnsArray = array);
public insertIgnore($tableName, $valueArray, $columnsArray = array);
public replace($tableName, $valueArray, $columnsArray = array);

public getLastId();
public lastId();

public getRowCount();

public beginTransaction();
public start();

public executeTransaction();
public finish();
public commit();

public rollBack();
public cancel();

public lock($tableNames);

public unlock();

public query($sql, ...value)

public select($sql, ...value)

public selectCell($sql, ...value);

public selectRow($sql, ...value);

public selectArray($sql, ...value);

public selectHash($sql, ...value);

public insert($tableName, $valueArray, $columnsArray = array);
public insertIgnore($tableName, $valueArray, $columnsArray = array);
public replace($tableName, $valueArray, $columnsArray = array);

  $db = new Database\Database('localhost', 'dbname', 'user', 'password');
  $result = $db->select('SELECT COLUMN1, COLUMN2, COLUMN3 FROM `table_name` WHERE COLUMN4 = ?s AND COLUMN5 = ?i OR COLUMN6 = ?', 'column4', 5, 'column6');

 $db->insert('table_name', array(array('COLUMN1' => 123, 'COLUMN2' => 123), array(234, 234), array(345, 345), array(456, 456)));
 $db->insert('table_name', array(123, 123));
 $db->insertIgnore('table_name', array(array(123, 123), array(234, 234), array(345, 345), array(456, 456)), array('COLUMN1', 'COLUMN2'));
 $db->replace('table_name', array(123, 123), array('COLUMN1', 'COLUMN2'));

select('SELECT * FROM `table_name` WHERE `COLUMN1` = ? OR `COLUMN2` = ?', 'VALUE', 5);

select('SELECT * FROM ?r WHERE `?r` > 1', '`table_name`', 'COLUMN');

select('SELECT * FROM `table_name` WHERE `COLUMN` = ?i', 23);

select('SELECT * FROM `table_name` WHERE `COLUMN` = ?s', 'string');

select('SELECT * FROM `table_name` WHERE `COLUMN` = ?f OR `COLUMN` = ?f', 3.1415926535, '2.71828');

select('SELECT * FROM `table_name` WHERE `COLUMN` = ?s', 'string');

select('SELECT * FROM `table_name` WHERE `COLUMN` IN (?a)', array(10, '20', '30', 40.3));

select('SELECT * FROM `table_name` WHERE `COLUMN` IN (?j)', array('p', 'd', 'o'));

select('UPDATE `table_name` SET ?h', array('COLUMN1' => 'One', 'COLUMN2' => 'Two', 'COLUMN3' => 'Three'));

select('SELECT * FROM `table_name` WHERE ?w', array('COLUMN1' => 'Three', 'COLUMN2' => 'Two', 'COLUMN3' => 'One'));

select('SELECT * FROM `table_name` WHERE `COLUMN` = :val OR `COLUMN` :val2', array(':val' => 'VALUE', ':val2' => 'VALUE'));
sql
SELECT * FROM `table_name` WHERE `COLUMN1` = 'VALUE' OR `COLUMN2` = 5;
sql
SELECT * FROM `table_name` WHERE `COLUMN` > 1;
sql
SELECT * FROM `table_name` WHERE `COLUMN` = 23;
sql
SELECT * FROM `table_name` WHERE `COLUMN` = '3.1415926535' OR `COLUMN` = '2.71828';
sql
SELECT * FROM `table_name` WHERE `COLUMN1` = 'Three' AND `COLUMN2` = 'Two' AND `COLUMN3` = 'One';
sql
SELECT * FROM `table_name` WHERE `COLUMN` = 'VALUE' OR `COLUMN2` = 'VALUE';