2017 © Pedro Peláez
 

library lib-db

PDO wrapper library with helpers

image

openlss/lib-db

PDO wrapper library with helpers

  • Thursday, May 2, 2013
  • by nullivex
  • Repository
  • 1 Watchers
  • 2 Stars
  • 179 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 17 Versions
  • 0 % Grown

The README.md

openlss/lib-db

PDO wrapper library with helpers, (*1)

The Db class tracks query counts and can debug queries. It will auto-generate SQL for insert/update queries., (*2)

Usage

//connect
Db::_get()->setConfig($dbconfig)->connect();

//execute a fetch
$result = Db::_get()->fetch('SELECT * FROM `table` WHERE `col` = ?',array($col));

Reference

Call to PDO

Any functions not shown in the reference are passed directly to PDO, (*3)

Singleton Information

Db can be and is recommended to be used as a singleton to reuse the same PDO instance., (*4)

If multiple connections are needed use a custom method of maintaining the instances., (*5)

($this) Db::setConfig($config)

Sets the config of the database system., (*6)

Takes an array with the following structure, (*7)

$config = array(
     'driver'       =>  'mysql'
    ,'database'     =>  'database_name'
    ,'host'         =>  'server_host'
    ,'port'         =>  'server_port'
    ,'user'         =>  'username'
    ,'password'     =>  'password'
);

($this) Db::connect()

Will use the current configuration and connect, (*8)

(int) Db::getQueryCount()

Returns the current query count, (*9)

(bool) Db::close()

Close the open PDO istance (if any), (*10)

(array) Db::prepWhere($pairs,$type='WHERE')

Prepares WHERE strings to be used in queries * $pairs array of clauses which can be in 4 formats * 'field-name' => array($bool='AND',$operator='=',$value) * 'field-name' => array($operator='=',$value) //bool defaults to AND * 'field-name' => array($operator) //bool defaults to AND, value defaults to NULL * 'field-name' => $value //bool defaults to AND, operator defaults to = * NOTE: use Db::IS_NULL and Db::IS_NOT_NULL for null value operators * $type specify the start of the string defaults to 'WHERE' * returns an array, with members: * [0] the resulting WHERE clause; compiled for use with PDO::prepare including leading space (ready-to-use) * [n] the values array; ready for use with PDO::execute, (*11)

(int) Db::insert($table,$params=array(),$update_if_exists=false)

Insert into a table with given parameters, (*12)

When $update_if_exists is set to TRUE it will perform an INSERT OR UPDATE query., (*13)

(bool) Db::update($table,$keys=array(),$params=array())

Updates a record in the database * $table The table to be updates * $keys Pairs compatible with prepWhere * $params Array of name=>value pairs to update with, (*14)

(result) Db::fetch($stmt,$params=array(),$throw_exception=Db::NO_EXCEPTIONS,$except_code=null,$flatten=Db::NO_FLATTEN)

Fetches a single row from a query and returns the result * $stmt The SQL query * $params Parameters to be bound to the query * $throw_exception When set to Db::EXCEPTIONS will throw an exception on result not found * $except_cde Code to be throw with the exception * $flatten When set to Db::FLATTEN will return an array of values from a specific column, (*15)

(array result) Db::fetchAll($stmt,$params=array(),$throw_exception=Db::NO_EXCEPTIONS,$except_code=null,$flatten=Db::NO_FLATTEN)

Same as fetch but returns all results in an array, (*16)

The Versions

02/05 2013

dev-master

9999999-dev http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

database pdo mysql database abstraction

09/04 2013

dev-0.0.x-dev

dev-0.0.x-dev http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

database pdo mysql database abstraction

09/04 2013

0.0.15

0.0.15.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

database pdo mysql database abstraction

07/04 2013

0.0.11

0.0.11.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

database pdo mysql database abstraction

07/04 2013

0.0.12

0.0.12.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

database pdo mysql database abstraction

07/04 2013

0.0.13

0.0.13.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

database pdo mysql database abstraction

07/04 2013

0.0.14

0.0.14.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

database pdo mysql database abstraction

03/04 2013

0.0.10

0.0.10.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

database pdo mysql database abstraction

28/03 2013

0.0.8

0.0.8.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

database pdo mysql database abstraction

28/03 2013

0.0.9

0.0.9.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

database pdo mysql database abstraction

27/03 2013

0.0.7

0.0.7.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

database pdo mysql database abstraction

26/03 2013

0.0.6

0.0.6.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

database pdo mysql database abstraction

26/03 2013

0.0.5

0.0.5.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

database pdo mysql database abstraction

26/03 2013

0.0.4

0.0.4.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

database pdo mysql database abstraction

26/03 2013

0.0.3

0.0.3.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

database pdo mysql database abstraction

23/03 2013

0.0.2

0.0.2.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPL-3.0+

The Requires

 

database pdo mysql database abstraction

21/03 2013

0.0.1

0.0.1.0 http://openlss.org

PDO wrapper library with helpers

  Sources   Download

LGPLv2

The Requires

  • php >=5.3.2

 

database pdo mysql database abstraction