2017 © Pedro Peláez
 

library pdobase

PDOBase. Wrapper for PDO

image

gooddaykya/pdobase

PDOBase. Wrapper for PDO

  • Thursday, March 1, 2018
  • by gooddaykya
  • Repository
  • 0 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

PDOBase

Latest Stable Version Total Downloads License, (*1)

Wrapper for PDO


Description

What it is?

PDOBase is a lightweight and easy-to-config wrapper for PDO. It hides most of routine under boilerplate, thus a developer can focus on what should be done instead of how it should be done., (*2)

What it is not?

PDOBase is not a query builder and doesn't include one., (*3)

Two reasons for this: 1. Supporting every SQL feature will add complexity to existing class., (*4)

2. Query builder, separated from specific database adaptor, becomes reusabe with another adaptors, that use SQL.

Using

Instantiating
    require '../vendor/autoload.php';

    $requisites = array(
        'host' => 'localhost',
        'user' => 'root',
        'charset' => 'utf8',
        'dbname'  => 'test_base',
        'password' => ''
    );

    $db = new \gooddaykya\components\PDOBase($requisites);

Or, by passing array from external file, (*5)

    require '../vendor/autoload.php';

    $db = new \gooddaykya\components\PDOBase(require '../requisites.php');
Getting data from database
    $result = $db->execQuery('SELECT * FROM const_table')('fetchAll');
Using prepared statements
    $request = 'SELECT val, textval FROM const_base WHERE id = :id';
    $bindParams = array(
        ':id' => 1
    );

    $result = $db->execQuery($request, $bindParams)('fetch');
ACID example
    $primeRequest = 'INSERT INTO main_table (val) VALUES (:val)';
    $dependentReq = 'INSERT INTO dep_table (id, val) VALUES (:id, :val)';

    try {
        $db->beginTransaction();
        $insertedId = $db->execQuery($primeRequest,
            array(':val' => 'Independent value')
        )('lastInsertId');

        $result = $db->execQuery(
            $dependentReq,
            array(
                ':id' => $insertedId,
                ':val' => 'Dependent value'
            )
        )('rowCount');

        $db->commit();
    } catch (\PDOException $e) {
        $db->rollback();
    }

Testing

Testing tables
const_table
id: unsigned int, not null, primary, AI val: unsigned int, not null textval: varchar(20)
1 0
2 1 one
3 1 One
4 2 Two
5 13 Trirteen
6 42 Universal answer
main_table
id: unsigned int, not null, primary, AI val: unsigned int, not null
dep_table foreign key(main_table.id)
id: unsigned int, not null, primary val: unsigned int, not null

ToDo List

[ ] separate current test cases into transaction and non transaction suites., (*6)

[ ] retrieve expected results directly from database., (*7)


EOF

The Versions

01/03 2018

dev-master

9999999-dev

PDOBase. Wrapper for PDO

  Sources   Download

MIT

The Requires

  • php >=5.3
  • ext-pdo *
  • ext-pdo_mysql *

 

The Development Requires

by Avatar gooddaykya

sql pdo mysql database wrapper

01/03 2018

dev-test-refactor

dev-test-refactor

PDOBase. Wrapper for PDO

  Sources   Download

MIT

The Requires

  • php >=5.3
  • ext-pdo *
  • ext-pdo_mysql *

 

The Development Requires

by Avatar gooddaykya

sql pdo mysql database wrapper

01/03 2018

v1.2-stable

1.2.0.0

PDOBase. Wrapper for PDO

  Sources   Download

MIT

The Requires

  • php >=5.3
  • ext-pdo *
  • ext-pdo_mysql *

 

The Development Requires

by Avatar gooddaykya

sql pdo mysql database wrapper

01/03 2018

dev-new-tests

dev-new-tests

PDOBase. Wrapper for PDO

  Sources   Download

MIT

The Requires

  • php >=5.3
  • ext-pdo *
  • ext-pdo_mysql *

 

The Development Requires

by Avatar gooddaykya

sql pdo mysql database wrapper

25/01 2018

dev-quickpatch

dev-quickpatch

PDOBase. Wrapper for PDO

  Sources   Download

MIT

The Requires

  • php >=5.3
  • ext-pdo *
  • ext-pdo_mysql *

 

The Development Requires

by Avatar gooddaykya

sql pdo mysql database wrapper

25/01 2018

v1.1.1

1.1.1.0

PDOBase. Wrapper for PDO

  Sources   Download

MIT

The Requires

  • php >=5.3
  • ext-pdo *
  • ext-pdo_mysql *

 

The Development Requires

by Avatar gooddaykya

sql pdo mysql database wrapper

23/01 2018

v1.1-stable

1.1.0.0

PDOBase. Wrapper for PDO

  Sources   Download

MIT

The Development Requires

by Avatar gooddaykya

23/01 2018

dev-src

dev-src

PDOBase. Wrapper for PDO

  Sources   Download

MIT

The Development Requires

by Avatar gooddaykya

23/01 2018

dev-tests

dev-tests

PDOBase. Wrapper for PDO

  Sources   Download

MIT

The Development Requires

by Avatar gooddaykya

12/01 2018

dev-struct

dev-struct

PDOBase. Wrapper for PDO

  Sources   Download

MIT

The Development Requires

by Avatar gooddaykya

12/01 2018

v1.0.0

1.0.0.0

PDOBase. Wrapper for PDO

  Sources   Download

MIT

The Development Requires

by Avatar gooddaykya