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

Overview

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

You might also like...
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.

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,

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

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

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

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

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

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

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

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,

Comments
  • Drop HHVM and use the build matrix

    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

    opened by photodude 3
  • Update not work?

    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();
    
    opened by crysan 2
Releases(v1.1.5)
Owner
Kodols
Kodols
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

Abdul Raheem 4 Jun 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

Mr Crypster 17 Oct 13, 2022
API abstracting communication with SQL providers (eg: MySQL) on top of PDO inspired by Java JDBC

SQL Data Access API Table of contents: About Configuration Execution Installation Unit Tests Examples Reference Guide About This API is a ultra light

Lucian Gabriel Popescu 0 Jan 9, 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 )

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

null 3 Feb 14, 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

Paragon Initiative Enterprises 704 Nov 14, 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

Jamie Matthews 2k Nov 27, 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

Woody Gilk 616 Nov 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

Jens Segers 6.3k Dec 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

Rexhep Shijaku 159 Nov 30, 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

Fabian de Laender 313 Oct 11, 2022