Simple MySQL library for PHP 5.4+ includes Query Builder, PDO Native functions, Helper functions for quick use.

Last update: Apr 19, 2022

MySQL Library for PHP

Build Status Latest Stable Version Total Downloads License

This library will give you access to everything you need from MySQL in PHP.

See our Object Reference to learn what is possible, or view our demo folder for examples.

About

The library is a hybrid between PHP's PDO and generic query building.

Started as a helper class for in-house projects and grown into a usefull tool for Kodols Ltd. A decision was made to make this library public give others the chance to use a well oriented library for database management.

Library will keep getting support and upgrades as this has been become the goto library for Kodols Ltd. to use for our projects.

This library supports access to the native PDO methods, few helper methods to simplify commonly used methods and a query builder to really give you access to build cool statements.

Prerequisites

This library will work on PHP 5.4 or later

Installing

You can clone this git repository into your project

git clone git://github.com/kodols/PHP-MySQL-Library.git

or you can use composer

composer require kodols/php-mysql-library

Deployment

The integration process is very simple, you call the main library class, add a configuration and you are all set. However we would recommend spend some time to really prepare the environment so you get the best out of this library. The library is based in src/ with its namespace \Kodols\MySQL. In our examples we will use a demo variable $KML (Kodols MySQL Library), but of course you can use any variable you like.

$KML = new \Kodols\MySQL\Library;

Once you have successfuly create the object you need to add MySQL connection details to it. The library supports multiple configurations attached and multiple connections established in the same request.

$config = $KML->newConfiguration();
$config->setHostname('my.host.com');
$config->setUsername('web');
$config->setPassword('42412');
$config->setDatabase('project');

The $config variable is \Kodols\MySQL\Configuration object, see Wiki for in depth details.

Once configuration is created you can attach it to the main library via $KML->attachConfiguration($config); and start using the library. However if your environment has multiple database endpoints, or maybe you have production, development and local environment, then you can setup it as follows:

$config = $KML->newConfiguration();
$config->setHostname('my.host.com');
...
$KML->attachConfiguration($config, 'live');

So when you call the server variable you can choose with of the server endpoints you want to use.

Contributors

We welcome a good idea, bug fixes, suggestions and requests. This list will be updated every time a new contribution has been made.

License

This project is licensed under the MIT License - see the https://github.com/kodols/php-mysql-library/blob/master/LICENSE file for details

GitHub

https://github.com/kodols/php-mysql-library
You might also like...

SQL database access through PDO.

Aura.Sql Provides an extension to the native PDO along with a profiler and connection locator. Because ExtendedPdo is an extension of the native PDO,

May 23, 2022

You can sync any number of PDO supported databases

Features: Can backup any number of databases. No need to introduce column name only table name The Last id based data backup Support 12 different data

Aug 27, 2021

Independent query builders for MySQL, PostgreSQL, SQLite, and Microsoft SQL Server.

Aura.SqlQuery Provides query builders for MySQL, Postgres, SQLite, and Microsoft SQL Server. These builders are independent of any particular database

Jun 21, 2022

Eloquent Filter is a package for filter data of models by the query strings. Easy to use and fully dynamic.

Eloquent Filter is a package for filter data of models by the query strings. Easy to use and fully dynamic.

Eloquent Filter Eloquent Filter adds custom filters to your Eloquent Models in Laravel. It's easy to use and fully dynamic. Table of Content Introduct

Jun 26, 2022

MongoDB ORM that includes support for references,embed and multilevel inheritance.

MongoDB ORM that includes support for references,embed and multilevel inheritance.

Introduction Features Requirements Installation Setup Database Basic Usage - CRUD Relationship - Reference Relationship - Embed Collection Inheritance

Apr 26, 2022

A PHP client driver for the RethinkDB query language (ReQL).

PHP-RQL A PHP client driver for the RethinkDB query language (ReQL).

Jun 6, 2022

Database Abstraction Layer, Schema Introspection, Schema Generation, Query Builders

Cycle DBAL Secure, multiple SQL dialects (MySQL, PostgreSQL, SQLite, SQLServer), schema introspection, schema declaration, smart identifier wrappers,

May 24, 2022

The query filter bundle allows you to filter data from QueryBuilder and the Database

The query filter bundle allows you to filter data from QueryBuilder and the Database

The query filter bundle allows you to filter data from QueryBuilder and the Database. you can filter multiple columns at the same time and also you can filter relation fields with two-level deep and without any join in your query builder.

Apr 8, 2022

Monadic Doctrine repositories helper classes and services.

Doctrine Repository Monadic Helper Description This project provides the necessary classes and services to use Doctrine repositories in a more functio

Jan 9, 2022
Comments
  • 1. Drop HHVM and use the build matrix

    HHVM LTS 3.24 is the last version to support PHP 5 compatibility third paragraph states "HHVM will not aim to target PHP7" and further down "We do not intend to be the runtime of choice for folks with pure PHP7 code." (just HACK) https://hhvm.com/blog/2017/09/18/the-future-of-hhvm.html

    add PHP 7.2 Uses build matrix uses sudo false for faster container based testing when sudo is not required fixes the travis build by setting the proper composer dev requirements for PHPunit versions

    Reviewed by photodude at 2018-03-29 18:33
  • 2. Update not work?

    Hi!

    $db->build('update')->table('tblUsers')->set('book_sel', '=' , '1')->where('id', '=', '1')->execute();

    return Call to a member function where() on null (0).

    And why did several types of operations?

    $db->**build**('update')
    	->table('users')
    	->set('username','=','ed')
    	->set('update_count','=','update_count + 1',true)
    	->where('id','=','1234')
    	->execute();
    
    $db->**builder**('update')
    	->table('original','a')
    	->join('updated','b','innser')
    	->on('a.URL','=','b.URL')
    	->set('a.funded','=','b.funded',true)
    	->set('a.days','=','b.days',true)
    	->execute();
    
    Reviewed by crysan at 2017-08-22 05:56
Very easy to use PDO MYSQL API. Just Include in PHP file and get it working.

CRUD-MYSQL-API Very easy to use PDO MYSQL API. Just Include in PHP file and get it working. INSTALATION Step 1: git clone https://github.com/arhex-lab

Jun 14, 2022
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way. ( WEBSITE VERSION )
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way. ( WEBSITE VERSION )

Mysql Optimizer mysql optimizer also known as MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query

Feb 14, 2022
Tiny php mysql lib (PDO-based) with handy fetch/update functionality, supports both SQL and parametric queries

Micro PHP mysql lib (~ 200 lines of code) with ultra powerful CRUD for faster than ever development: parametric fetch/insert/update/delete (based on a

Feb 22, 2022
Easy-to-use PDO wrapper for PHP projects.

EasyDB - Simple Database Abstraction Layer PDO lacks brevity and simplicity; EasyDB makes separating data from instructions easy (and aesthetically pl

Jun 19, 2022
A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5.

Idiorm http://j4mie.github.com/idiormandparis/ Feature/API complete Idiorm is now considered to be feature complete as of version 1.5.0. Whilst it wil

Jun 21, 2022
A SQL query builder with zero dependencies

Latitude Query Builder A SQL query builder with zero dependencies. Attempts to be PSR-1, PSR-2, and PSR-4 compliant. Install composer require latitude

Jun 24, 2022
A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

Laravel MongoDB This package adds functionalities to the Eloquent model and Query builder for MongoDB, using the original Laravel API. This library ex

Jul 3, 2022
SQL to Laravel Query Builder

Marwan - SQL To Laravel Builder SQL to Laravel Query Builder, A Converter written in PHP Features Converts SQL Queries to Laravel Query Builder. Assis

Jun 12, 2022
Just another PDO database library

PDO Just another PDO database library Installation Use Composer $ composer require faapz/pdo Usage Examples selecting, inserting, updating and deletin

May 29, 2022
A simple program to query mysql data and display the queried data in JSON format

A simple program to query mysql data and display the queried data in JSON format. The data displayed in JSON format will change and update as the data in your mysql database changes.

Mar 7, 2022