unreal4u / db_mysqli

This package implements a MySQL database access wrapper using the MySQLi extension
1 stars 0 forks source link

dbmysqli.php

Important: deprecated

Please don't use this code... like ever. WAY WAY WAAAAY better options exist nowadays. I'm archiving this repository as well.

Credits

This class is made by unreal4u (Camilo Sperberg). http://unreal4u.com/. However, the initial idea isn't mine, so I would like to thank Mertol Kasanan, this class is based on his work. See http://www.phpclasses.org/browse/package/5191.html for details.

About this class

Detailed description

This package implements a MySQL database access wrapper using the MySQLi extension.

There is class that manages MySQL database access connections so only one connection is established during the same PHP script execution.

Another class implements other database access functions like executing queries with prepared queries, measuring the time the queries take to execute and the memory usage, retrieving query results into arrays, the number of result rows, last inserted record identifier and log executed queries to a valid XML log file or directly into your page.

If the query takes just too long, you can cache the query result into an XML file, and you can also handle errors.

This package has been extensivily tested with xDebug, APC and Suhosin so that no errors are present.

Basic usage

include('src/unreal4u/config.php'); // Please see below for explanation
include('src/unreal4u/dbmysqli.php');
$dbLink = new unreal4u\dbmysqli();
$id_user = 23;
$username = 'unreal4u';
$aResult = $dbLink->query('SELECT id,username FROM users WHERE id = ? AND username = ?',$id_user,$username);
foreach($aResult AS $a) {
  echo 'The id of the user named '.$a['username'].' is: '.$a['id']."\n";
}

Including with composer

Add this to your composer.json:

{
   "require": {
       "unreal4u/dbmysqli": "@stable"
   }
}

Now you can instantiate a new dbmysqli class by executing:

require('vendor/autoload.php');

$rutverifier = new unreal4u\dbmysqli();

Pending ---------

Version History

Contact the author