thecsea/mysqltcs

The simplest and the most powerful library to access to a mysql database, optimizing the connections and allowing you to perform common database actions immediately and efficiently

v3.1.0 2015-10-05 14:22 UTC

README

Build status: Build Status Scrutinizer Code Quality Code Coverage Build Status Latest Stable Version Total Downloads Latest Unstable Version License

The simplest and the most powerful library for mysql written in php:

  • You can use the same db connection in more than one instances (optimizing mysql physical connections)
  • This library allow you to make common database operations immediately and efficiently, returning simple data structures
  • Log all actions performed on db
  • All mysql error as exception
  • Clone support
  • Transactions support

Download, install and use

Download

via git

Clone repository

git clone https://github.com/thecsea/mysqltcs.git

via composer

download composer here https://getcomposer.org/

add the following dependence in composer.json

"thecsea/mysqltcs": "3.0.*"

or type

php composer.phar require thecsea/mysqltcs

##Install/Update Update composer (download composer here https://getcomposer.org/)

php composer.phar self-update

Followings commands must be executed in project root directory

###Install mysqltcs

php composer.phar install

###Update mysqltcs

You can perform an updated if you have added mysqltcs as composer dependency

php composer.phar update

You have to perform an update when a new version is released

##How to use

When composer installation is finished you will see vendor/autoload.php that is the auload generated by composer. If you have set mysqltcs as composer dependence the autoload loads both mysqltcs and other dependecies. So you just have to include autload in each file where you want use mysqltcs and create the mysqtcs object in the following way:

$connection = new it\thecsea\mysqltcs\Mysqltcs(...);

or

use it\thecsea\mysqltcs\Mysqltcs; and $connection = new Mysqltcs(...);

You can see examples to understand how to use library

You can also take a look to wiki to see the detailed description or go to generated phpdoc documents (documentations of all classes)

Tests

Mysqltcs is tested with automatic test: phpunit test. So we have a good chance of not having errors, but not the certainty. But we have covered the following percentage of statements with tests: Code Coverage

  • Change db data in tests/config.php
  • Import tests/mysqltcs.sql
  • Execute the unit tests:
  1. Go in the root directory
  2. Type phpunit or if you have downloaded the phar php phpunit-xxx.phar

In fact phpunit.xml contains the correct test configuration

CAUTION: each time tests are executed, the database must be in the initial state, like the import has just been executed (you should have a empty table, only the db structure)

#Examples You can find some examples under examples to run it:

  • Change db data in examples/config.php
  • Import examples/mysqltcs.sql

There is a simple example simpleExample.php that shows you how to use the library in the simplest way

There are not examples about transactions yet (you have to remember to set autocommit to true after using transactions)

N.B. if you have added mysqltcs as composer dependency you will find example under vendor/thecsea/mysqltcs/examples

By thecsea.it