2017 © Pedro Peláez
 

library db

DB wrapper in PHP (pdo, mysqli)

image

phpdudimanche/db

DB wrapper in PHP (pdo, mysqli)

  • Sunday, November 6, 2016
  • by phpdudimanche
  • Repository
  • 1 Watchers
  • 1 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

DataBaseConnection Wrapper

A simple PHP DataBase Connection Library Wrapper. The goal is to be simple and to be close the native libraries : mysqli, pdo., (*1)

Principle

The goal is to have the less to maintain. If you have known different versions of php, of Pear db and mdb2... you know it is unpleasant to update large code sections., (*2)

Use

There are two versions :, (*3)

  • procedural DB :

$conn = connect();, (*4)

  • object DB with prepared statements :

$myDB= new $db;
$connection=$myDB->connect();, (*5)

Param

The config file contains your connection params :, (*6)

$host="";
$database="";
$user="";
$pass="";, (*7)

These variable names are used in connect() function. So, if names are differents, change it in these two places., (*8)

In the procedural example, a global name is used to use connection : $conn = connect(). If you change this param name, in procedural you have to change this name in all function., (*9)

In order to switch beetween PDO and mysqli :, (*10)

$db= 'pdo';// OR 'mysqli', (*11)

You or i have just the lib to maintain. And to ensure this is correctly maintenaid beetween mysqli and pdo, in POO there is an interface., (*12)

Installation

You have just to include this lib, as dir (or as a composer package - https://packagist.org/). In your composer.json file in your root, add :, (*13)

 "require": {
   "phpdudimanche/db": "00.00"
},
  "autoload": {
  "psr-4": {
      "Phpdudimanche\\Db\\": "phpdudimanche/poo/"
      }
  }

In your composer console write :, (*14)

composer update

Test

With each version, you have a test file, just to run and to see. No testing tool needed. Tests can be used as examples., (*15)

WARNING : there are three potential bugs :, (*16)

  • autoincrement (depends on your config : browser, VPN)
  • rollback (depends on your config : autocommit, server)
  • transaction (mysqli REPORT_ALL used in transaction test finds a fatal error in query "select * from tablename").

The Versions

06/11 2016

dev-master

9999999-dev

DB wrapper in PHP (pdo, mysqli)

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0

 

06/11 2016

00.00

00.00.0.0

DB wrapper in PHP (pdo, mysqli)

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0