MySQL query builder PHP class

I am creating an application that must have a MySQL query designer in OOP style. I want to be able to flexibly build complex queries using only PHP and get the final query string to execute using my own database driver.

Does anyone know of a good standalone query builder for PHP? Please note that I do not need a database driver. I need an empty builder MySQL query class (preferably written with a camel-style function and variable names).

+6
source share
4 answers

Finally I took the Doctrine ORM

and slightly modified it to build SQL instead of DQL .

This works very well and is capable of creating complex queries.

Edit: You can find my final stable implementation in the Stingle framework. Check out the Db / QueryBuilder plugin.

+5
source

DSQL - Query Builder for PHP is exactly what you are looking for, no MIT dependencies and licenses:

$query = new atk4\dsql\Query(); $query ->table('employees') ->where('birth_date','1961-05-02') ->field('count(*)') ; echo "Employees born on May 2, 1961: ".$query->getOne(); 

https://github.com/atk4/dsql

Documentation: http://dsql.readthedocs.io/

+2
source

The PhpToolCase library has a standalone query building tool, which is quite simple and easy to use.

There is full support support: http://phptoolcase.com/guides/ptc-qb-guide.html

And ya seems to be written with camel-style function and variable names :)

+1
source

There is one version of the query builder (LGPL license). I have not used it, but you can take a look at it if it meets your goals: http://code.google.com/p/mysql-query-builder/

0
source

Source: https://habr.com/ru/post/912225/


All Articles