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

Overview

Aura.SqlQuery

Provides query builders for MySQL, Postgres, SQLite, and Microsoft SQL Server. These builders are independent of any particular database connection library, although PDO in general is recommended.

Installation and Autoloading

This package is installable and PSR-4 autoloadable via Composer as aura/sqlquery.

Alternatively, download a release, or clone this repository, then map the Aura\SqlQuery\ namespace to the package src/ directory.

Dependencies

This package requires PHP 5.6 or later; it has been tested on PHP 5.6, PHP 7, and HHVM. We recommend using the latest available version of PHP as a matter of principle.

Aura library packages may sometimes depend on external interfaces, but never on external implementations. This allows compliance with community standards without compromising flexibility. For specifics, please examine the package composer.json file.

Quality

Scrutinizer Code Quality Code Coverage Build Status

This project adheres to Semantic Versioning.

To run the unit tests at the command line, issue composer install and then ./vendor/bin/phpunit at the package root. This requires Composer to be available as composer.

This package attempts to comply with PSR-1, PSR-2, and PSR-4. If you notice compliance oversights, please send a patch via pull request.

Community

To ask questions, provide feedback, or otherwise communicate with other Aura users, please join our Google Group, follow @auraphp, or chat with us on Freenode in the #auraphp channel.

Documentation

This package is fully documented here.

Comments
  • Query generation in Aura\Sql

    Query generation in Aura\Sql

    Guys, hold the press for a minute - I think I may have just identified a misplaced feature (or a feature overlap) between Aura\Sql and Aura\Sql_Query.

    From the Aura\Sql README:

    named placeholders in prepared statements that are bound to array values will be replaced with comma-separated quoted values. This means you can bind an array of values to a placeholder used with an IN (...) condition

    This is great, but it has nothing to with "prepared statements" in PDO terms, and it's not strictly an "extension" to PDO - strictly speaking, it's query construction, which is supposed to to be Aura\Sql_Query's domain.

    According to the PHP manual, prepared statements:

    can be executed multiple times with the same or different parameters. When the query is prepared, the database will analyze, compile and optimize its plan for executing the query

    By throwing query construction for arrays into the mix, this is no longer true - as well as:

    By using a prepared statement the application avoids repeating the analyze/compile/optimize cycle

    This aspect of PDO is now no longer a given in ExtendedPdo - as you know, PDO does not support binding arrays to placeholders, but that is a shortcoming which cannot be addressed by extending the PDO class, since you are then no longer using prepared statements.

    While ExtendedPdo arguably "prepares statements", it does not extend the concept of "prepared statements" as defined by PDO. As such, support for binding arrays to statements can't be implemented in userland, because true support for prepared statements is something that requires PDO driver-level support; you don't have any control over the "analyze/compile/optimize cycle", which is an internal feature of PDO.

    An array of strings string[] or numbers int[] is a type, and what you're actually doing, is constructing SQL representations of values of those types, for use in SQL queries, which is query construction.

    You would not be doing that (and it wouldn't work) for any other types, such as date/time or boolean values. The reason it's even possible at all, without a driver abstraction (which ExtendedPdo does not have, and Sql_Query does) is that the syntax happens to be the same in every supported SQL engine - but that is not a given for any other type.

    In other words, this is a query construction concern, not preparation - and I would argue that this has no place in ExtendedPdo; query construction belongs in Aura\Sql_Query, which has a framework to support and handle driver-specific details of SQL generation.

    While Aura\Sql_Query is not currently equipped with any driver-specific value-to-SQL or SQL-to-value facilities, this is clearly something you found useful and necessary enough to support for arrays - so a more complete type/value handling facility is probably worth considering?

    PDO itself has very bare bones type management - only what is strictly required and/or supported by drivers, e.g. strings, numbers and NULL values. ExtendedPdo tacks on support specifically for arrays of strings, numbers and NULL values, and the end result is a little better, but still isn't by any means a generic framework for all types of values.

    Moving support for arrays out of the PDO extension into Sql_Query might be a logical first step towards a more complete (and more general) value formatting facility.

    What do you think?

    opened by mindplay-dk 71
  • Why the 5.4 dependency?

    Why the 5.4 dependency?

    Why the dependency on PHP 5.4?

    The new Aura\Sql is compatible with 5.3 - why the higher requirements for this component?

    I see you're using traits, and maybe that's why - but the problem you're solving with traits in this case can be solved just as well using composition rather than inheritance.

    Would you accept a pull-request, refactoring for PHP 5.3 compatibility (passing all unit-tests, keeping API identical to current API) or do I have to maintain my own fork?

    opened by mindplay-dk 22
  • Version 3: Update interfaces and nothing else

    Version 3: Update interfaces and nothing else

    There have been several questions lately regarding the fact that the interfaces do not match the classes. The disconnect is because the classes have had features added, but adding the relevant methods to the interface would be a BC break.

    Perhaps the time has come to update the interfaces, and in so doing move to version 3, with no other functionality changes.

    Thoughts?

    opened by pmjones 18
  • Should Queries Keep Track of Joined Tables?

    Should Queries Keep Track of Joined Tables?

    I'm building an application that uses a lot of other objects to modify an Aura query builder object.

    One issue I ran into is that the query builders don't keep track of joined tables. So something like this:

    use Aura\SqlQuery\QueryFactory;
    
    $factory = new QueryFactory('mysql');
    
    $select = $factory->newSelect();
    
    $select->cols([
        'SUM(clicks)' => 'clicks',
    ]);
    $select->from('some_table');
    $select->join('other', 'some_table.id = other.id');
    
    // some other object does it again
    $select->join('other', 'some_table.id = other.id');
    
    echo $select, PHP_EOL;
    

    I would expect the join to only be generated a single time, but that's not the case:

    SELECT
        SUM(clicks) AS `clicks`
    FROM
        `some_table`
    OTHER JOIN `some_table`.`id` `=` `other.id`
    OTHER JOIN `some_table`.`id` `=` `other.id`
    

    It's easy enough to solve with client code, but it seems like it might be a nice feature for the query builders in general.

    opened by chrisguitarguy 17
  • Group by [Feature]

    Group by [Feature]

    Hi,

    One of the missing feature I think about the library is creating grouping statements. I have been looking at https://github.com/paragonie/easydb#grouping-of-conditions .

    An example taken :

    $statement = EasyStatement::open()
        ->group()
            ->with('subtotal > ?')
            ->andWith('taxes > ?')
        ->end()
        ->orGroup()
            ->with('cost > ?')
            ->andWith('cancelled = 1')
        ->end();
    
    echo $statement; /* (subtotal > ? AND taxes > ?) OR (cost > ? AND cancelled = 1) */
    

    Does anyone like this feature ?

    opened by harikt 14
  • Add reset functionality on the Select class

    Add reset functionality on the Select class

    @yespire @golgote @gauthier @harikt --

    This PR is based on #84 from @yespire. It combines the resetFrom(), resetFromKey(), and resetTableRefs() into a single resetTables() method, and adds resetBindValues() and resetUnions(). It removes resetLimit(), resetOffset(), resetPage(), because those values are accessible through existing limit(), offset(), and page() methods. Finally, the resetFlags() method is made public instead of protected, and now returns $this.

    In summary, the newly-public reset methods are:

    • resetBindValues()
    • resetFlags()
    • resetCols()
    • resetTables()
    • resetWhere()
    • resetGroupBy()
    • resetHaving
    • resetOrderBy()
    • resetUnions()

    Thoughts?

    enhancement Need Release 
    opened by pmjones 13
  • Subquery should check for interface not extending abstractquery

    Subquery should check for interface not extending abstractquery

    The fix for using a subselect as a where item breaks when used with sqlmapper_bundle and anything else that might use composition instead of direct inheritance for a query builder class

    https://github.com/auraphp/Aura.SqlQuery/commit/bc4a1fb2a2d25a78d0b64432dddab5ac1f7d583c#diff-99f68aad8e6850c09d918a732ff868e3R333

    It fails with cannot bind value of type object to placeholder - in fact a nice feature might be to check for stringability in ANY object bound into a where

    In any case the current code is checking for direct inheritance of abstractquery, should probably use a different kind of check - or change sqlmapper_bundle to use more direct inheritance for it's query builder classes so things don't break

    opened by auroraeosrose 13
  • Postgre jsonb operators and placeholders

    Postgre jsonb operators and placeholders

    Hello!

    I have a problem with making select query with operator ?| that is used in postgre to check if two jsonb items have common keys. My query, written by hand and simplified for the example, is:

    select * 
    from table_name
    where phones::jsonb ?| ARRAY['71111111111', '71234567890']
    

    I used query builder like this:

    $queryFactory = new QueryFactory('pgsql');
    $select = $queryFactory->newSelect();
    
    $select->cols(['*'])
    ->from('table_name')
    ->where("phones::jsonb ?| ARRAY['71111111111', '71234567890']");
    
    $statement = $select->getStatement();
    

    but I got that (notice how "?" has been replaced. Builder supposes that it is placeholder for parameter):

    select * 
    from table_name
    where phones::jsonb :_1_| ARRAY['71111111111', '71234567890']
    

    So, what can I do to get rid off of this?

    opened by taxp 10
  • Insert multiple rows with a single query

    Insert multiple rows with a single query

    Is there a way to build a query that inserts multiple value sets?

    INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);

    If not, do you think it makes sense to add that functionality?

    enhancement 
    opened by jakeasmith 10
  • Allow reset for some query parts

    Allow reset for some query parts

    What about: public function orderBy(array $spec, $replace = false) instead of : public function orderBy(array $spec)

    This can be added to other clauses as well. I personally need this because my query is built by different objects and each adds some clauses that might later need to be replaced by others.

    enhancement 
    opened by golgote 9
  • getStatement not reconized in IDE

    getStatement not reconized in IDE

    When we build a select query :

        $factory= new QueryFactory("mysql");
        $query = $factory->newSelect(); 
        $query->getStatement();
    

    the method getStatement() is not reconized in the ide and that leads to confusion and maybe is it highlighting a mistake in the library design ?

    opened by gsouf 9
  • Named placeholder don't work in where()

    Named placeholder don't work in where()

    The documentation in examles allow to used named placeholders in where clause like this:

    // bind 'zim_val' to the :zim placeholder
    ->where('zim = :zim', ['zim' => 'zim_val'])
    

    But this will not work since named placeholders don't update bind_values internal property. The ->where() method only works with ?-placeholders which actually not documented at all. I've lost 2 hours trying to figure it out.

    $select = $queryFactory->newSelect()->cols(['*'])->from('table1')->where('col1 = :col1', ['col1' => 'value']);
    var_dump($select->getStatement());
    var_dump($select->getBindValues());
    

    This will print SQL query and empty array of bind values.

    Possible workaround could be using of additional bindValues():

    $select = $queryFactory->newSelect()->cols(['*'])->from('table1')->where('col1 = :col1')->bindValues(['col1' => 'value']);
    var_dump($select->getStatement());
    var_dump($select->getBindValues());
    

    or using ?-placeholder:

    $select = $queryFactory->newSelect()->cols(['*'])->from('table1')->where('col1 = ?', 'value');
    var_dump($select->getStatement());
    var_dump($select->getBindValues());
    

    But both variants looks dirty and not match documentation.

    P.S. Is this repo abandoned?

    opened by gugglegum 1
  • Allow passing query to `union()`

    Allow passing query to `union()`

    It would be convenient to be able to pass a query directly to union() instead of rerunning the same commands on the original query.

    Here's what I thought I would be able to do. I've simplified the queries from my RL example to make them easier to read. The more complicated the similar union()ed queries are, the more appreciated the requested change would be.

    $txns_by_owner = $this->queryBuilder->newSelect()
        ->cols($this->getBalanceFields())
        ->from('transactions AS t');
    
    // the two subqueries are mostly the same. Clone them now, add differing elements after
    $txns_by_property = clone $txns_by_owner;
    $txns_by_owner->where('t.owner_id = :owner_id');
    
    $txns_by_property
        ->join('INNER', 'properties AS p', 'p.property_id = t.property_id')
        ->where('p.owner_id = :owner_id')
    ;
    
    return $this->queryBuilder->newSelect()
        ->cols(['SUM(amount) AS amount'])
        ->fromSubSelect($txns_by_owner->union($txns_by_property));
    

    It seems what I actually have to do is this

    $subquery = $this->queryBuilder->newSelect();
    
    $subquery->cols($this->getBalanceFields())
        ->from('transactions AS t')
        ->where('t.owner_id = :owner_id')
    ;
    
    $subquery->union()
        ->cols($this->getBalanceFields())
        ->from('transactions AS t')
        ->join('INNER', 'properties AS p', 'p.property_id = t.property_id')
        ->where('p.owner_id = :owner_id')
    ;
    
    return $this->queryBuilder->newSelect()
        ->cols(['SUM(amount) AS amount'])
        ->fromSubSelect($subquery, 't1')
    ;
    
    opened by RentecTravis 0
  • Where with parentheses

    Where with parentheses

    Maybe I'm missing something... How would I replicate the following?

    where (
        find_in_set(tests.`compound.group`, :compound_groups) or
        find_in_set(tests.`compound.name`, :compound_names)
    )
    and (
        find_in_set(isolates.`species.genus`, :species_genera) or
        find_in_set(isolates.`species.name`, :species_names)
    )
    

    The parentheses are important in the above, and I can't figure out how I should do it with SQLQuery.

    opened by designermonkey 0
  • # in column name

    # in column name

    Working with an exsisting DB structure and they have # special char all over their column names in a DB2 database.

    Using ->orderBy( 'A.G01GL#' )

    results in the sql statement being

    ORDER BY "A"."G01GL"# ASC

    Any advice on how to get around this?

    opened by otelconsulting 2
  • Update '->where' method with binding params don't working

    Update '->where' method with binding params don't working

    Hi, everyone. Method 'where' with passed two params don't working for me. I do that ->where('gir = :gir', ['gir' => 'gir_val']) Also phpstorm shows warning with the text:

    Method call is provided 2 parameters, but the method signature uses 1 parameters.

    Screen Shot 2020-02-22 at 3 43 54 PM
    opened by FAST-JE 2
Releases(2.8.0)
  • 2.8.0(May 21, 2022)

    What's Changed

    • Splitting array parameters into multiple parametres for fix PDO excecution error "Array to string conversion" by @PHPCraftdream in https://github.com/auraphp/Aura.SqlQuery/pull/127
    • Added phpunit via composer by @syndicateSoftware in https://github.com/auraphp/Aura.SqlQuery/pull/128
    • Drop HHVM support v2.x by @odan in https://github.com/auraphp/Aura.SqlQuery/pull/154
    • Add WHERE IN example by @odan in https://github.com/auraphp/Aura.SqlQuery/pull/146
    • Correct preg_split call by @srjlewis in https://github.com/auraphp/Aura.SqlQuery/pull/190
    • Update ci to support from php 5.4 to 8.1 by @harikt in https://github.com/auraphp/Aura.SqlQuery/pull/203

    New Contributors

    • @PHPCraftdream made their first contribution in https://github.com/auraphp/Aura.SqlQuery/pull/127
    • @syndicateSoftware made their first contribution in https://github.com/auraphp/Aura.SqlQuery/pull/128
    • @srjlewis made their first contribution in https://github.com/auraphp/Aura.SqlQuery/pull/190

    Full Changelog: https://github.com/auraphp/Aura.SqlQuery/compare/2.7.1...2.8.0

    Source code(tar.gz)
    Source code(zip)
  • 3.0.0-alpha.1(May 21, 2022)

    What's Changed

    • fix phpDoc and broken return type in Common/Select.php by @pavarnos in https://github.com/auraphp/Aura.SqlQuery/pull/110
    • insert->col() and update->col() use variable argument lists by @pavarnos in https://github.com/auraphp/Aura.SqlQuery/pull/111
    • Docs structure and add changelog by @harikt in https://github.com/auraphp/Aura.SqlQuery/pull/113
    • make $bind parameters explicit in WhereInterface and in having() clauses by @pavarnos in https://github.com/auraphp/Aura.SqlQuery/pull/114
    • fix scrutinizer messages by @pavarnos in https://github.com/auraphp/Aura.SqlQuery/pull/117
    • move copy/pasted where() / orWhere() to WhereTrait by @pavarnos in https://github.com/auraphp/Aura.SqlQuery/pull/116
    • add missing public methods to SelectInterface and related. by @pavarnos in https://github.com/auraphp/Aura.SqlQuery/pull/112
    • add Insert::orReplace by @pavarnos in https://github.com/auraphp/Aura.SqlQuery/pull/115
    • improve test coverage by @pavarnos in https://github.com/auraphp/Aura.SqlQuery/pull/119
    • move copy/pasted limit()/offset() code to traits by @pavarnos in https://github.com/auraphp/Aura.SqlQuery/pull/120
    • add “composer test” command to composer.json by @pavarnos in https://github.com/auraphp/Aura.SqlQuery/pull/123
    • Extract builder logic to separate classes by @pmjones in https://github.com/auraphp/Aura.SqlQuery/pull/131
    • 3.x quoter by @pmjones in https://github.com/auraphp/Aura.SqlQuery/pull/132
    • Remove SubSelect interface, typehint on SelectInterface instead by @pmjones in https://github.com/auraphp/Aura.SqlQuery/pull/133
    • 3.x: Named placeholders only for where() et al. conditions by @pmjones in https://github.com/auraphp/Aura.SqlQuery/pull/134
    • Fixes #125 by @harikt in https://github.com/auraphp/Aura.SqlQuery/pull/135
    • Support 'grouping' of where() and having() conditions by @pmjones in https://github.com/auraphp/Aura.SqlQuery/pull/136
    • Only fall back to common quoter when DB-specific quoter doesn't exist by @djmattyg007 in https://github.com/auraphp/Aura.SqlQuery/pull/141
    • Add "table dot star" assertion to quoter test by @djmattyg007 in https://github.com/auraphp/Aura.SqlQuery/pull/140
    • Add missing closing ``` in docs/select.md by @johnchen902 in https://github.com/auraphp/Aura.SqlQuery/pull/144
    • Make travis use trusty by @jakejohns in https://github.com/auraphp/Aura.SqlQuery/pull/148
    • Drop HHVM support v3.x by @odan in https://github.com/auraphp/Aura.SqlQuery/pull/153
    • Test newer PHP versions on CI by @Bilge in https://github.com/auraphp/Aura.SqlQuery/pull/169
    • Explain how to bind IN conditions by @afilina in https://github.com/auraphp/Aura.SqlQuery/pull/175
    • fix minor typo in instantiation.md by @cameronsteele in https://github.com/auraphp/Aura.SqlQuery/pull/180
    • improve select.md orderBy example by @cameronsteele in https://github.com/auraphp/Aura.SqlQuery/pull/181
    • minor typo in select.md by @cameronsteele in https://github.com/auraphp/Aura.SqlQuery/pull/182
    • fixes #178 by @pmjones in https://github.com/auraphp/Aura.SqlQuery/pull/179
    • Enable PHP 5.6-8.1 compat in 3.x by @koriym in https://github.com/auraphp/Aura.SqlQuery/pull/195
    • Fix typos by @koriym in https://github.com/auraphp/Aura.SqlQuery/pull/196
    • Add to composer ext-pdo_sqlite which required for tests by @maximTarleckiy in https://github.com/auraphp/Aura.SqlQuery/pull/174
    • Fix types in phpdoc by @koriym in https://github.com/auraphp/Aura.SqlQuery/pull/197
    • Support inline array for condition by @syrm in https://github.com/auraphp/Aura.SqlQuery/pull/162
    • Refactor #162 by @koriym in https://github.com/auraphp/Aura.SqlQuery/pull/198
    • Add ignore() method to common Insert class by @maximTarleckiy in https://github.com/auraphp/Aura.SqlQuery/pull/173
    • Fix deprecated test method by @koriym in https://github.com/auraphp/Aura.SqlQuery/pull/199
    • Specify composer version to run up to PHP 7.1 with CI by @koriym in https://github.com/auraphp/Aura.SqlQuery/pull/202

    New Contributors

    • @djmattyg007 made their first contribution in https://github.com/auraphp/Aura.SqlQuery/pull/141
    • @johnchen902 made their first contribution in https://github.com/auraphp/Aura.SqlQuery/pull/144
    • @jakejohns made their first contribution in https://github.com/auraphp/Aura.SqlQuery/pull/148
    • @Bilge made their first contribution in https://github.com/auraphp/Aura.SqlQuery/pull/169
    • @afilina made their first contribution in https://github.com/auraphp/Aura.SqlQuery/pull/175
    • @cameronsteele made their first contribution in https://github.com/auraphp/Aura.SqlQuery/pull/180
    • @maximTarleckiy made their first contribution in https://github.com/auraphp/Aura.SqlQuery/pull/174
    • @syrm made their first contribution in https://github.com/auraphp/Aura.SqlQuery/pull/162

    Full Changelog: https://github.com/auraphp/Aura.SqlQuery/compare/2.7.1...3.0.0-alpha1

    Source code(tar.gz)
    Source code(zip)
  • 2.7.1(Oct 3, 2016)

  • 2.7.0(Sep 2, 2016)

    • [DOC] Numerous docblock and README updates.
    • [ADD] Add various Select::reset*() methods. Fixes #84, #95, #94, #91.
    • [FIX] On SELECT, allow OFFSET even when LIMIT not specified. Fixes #88.
    • [FIX] On SELECT, allow join*() before from*(). Joins-before-from are added to the first from. If no from is ever added, the joins will never be built into the statement. Fixes #69, #90.
    • [BRK] Bumped the minimum version to PHP 5.3.9 (vs 5.3.0). Fixes #74. This is to address a language-level bug in PHP. Technically I think this is a BC break, but I hope it is understandable, given that PHP 5.3.x is end-of-life, and that Aura.SqlQuery itself simply will not operate on versions earlier than that. Updated README to reflect the version requirement.
    Source code(tar.gz)
    Source code(zip)
  • 2.6.0(Nov 9, 2015)

    • (DOC) Docblock and README updates; in particular, add an @method getStatement() to the QueryInterface for IDE auto-completion.
    • (ADD) Select::hasCols() reports if there are any columsn in the Select.
    • (ADD) Select::getCols() gets the existing columns in the Select.
    • (ADD) Select::removeCol() removes a previously-added column.
    • (FIX) Select::reset() now properly resets the table refs for a UNION.
    • (FIX) Select::forUpdate() is now fluent.
    Source code(tar.gz)
    Source code(zip)
  • 2.5.0(Jun 2, 2015)

    • Docblock and README updates
    • The Common\Select class, when binding values from a subselect, now checks for instanceof SubselectInterface instead of self; the Select class now implements SubselectInterface, so this should not be a BC break.
    • Subselects bound as where/having/etc conditions should now retain ?-bound params.
    Source code(tar.gz)
    Source code(zip)
  • 2.4.2(Mar 27, 2015)

  • 2.4.1(Mar 26, 2015)

  • 2.4.0(Mar 22, 2015)

    This release incorporates two feature additions and one fix.

    • ADD: The Insert objects now support multiple-row inserts with the new addRow() and addRows() methods.
    • ADD: The MySQL Insert object now supports ON DUPLICATE KEY UPDATE functionality with the new onDuplicateKeyUpdate*() methods.
    • FIX: The Select methods regarding paging now interact better with LIMIT and OFFSET; in particular, setPaging() now re-calculates the LIMIT and OFFSET values.
    Source code(tar.gz)
    Source code(zip)
  • 2.3.0(Mar 16, 2015)

    This release has several new features.

    1. The various join() methods now have an extra $bind param that allows you to bind values to ?-placeholders in the condition, just as with where() and having().
    2. The Select class now tracks table references internally, and will throw an exception if you try to use the same table name or alias more than once.
    3. The method getStatement() has been added to all queries, to allow you to get the text of the statement being built. Among other things, this is to avoid exception-related blowups related to PHP's string casting.
    4. When binding a value to a sequential placeholder in where(), having(), etc, the Select class now examind the value to see if it is a query object. If so, it converts the object to a string and replaces the ?-placeholder inline with the string instead of attempting to bind it proper. It also binds the existing sequential placholder values into the current Select in a non-conflicting fashion. (Previously, no binding from the sub-select took place at all.)
    5. In fromSubSelect() and joinSubSelect(), the Select class now binds the sub-select object sequential values to the current Select in a non-conflicting fashion. (Previously, no binding from the sub-select took place at all.)

    The change log follows:

    • REF: Extract rebuilding of condition and binding sequential values.
    • FIX: Allow binding of values as part of join() methods. Fixes #27.
    • NEW: Method Select::addTableRef(), to track table references and prevent double-use of aliases. Fixes #38.
    • REF: Extract statement-building to AbstractQuery::getStatement() method. Fixes #30.
    • FIX: #47, if value for sequential placeholder is a Query, place it as a string inline
    • ADD: Sequential-placeholder prefixing
    • ADD: bind values from sub-selects, and modify indenting
    • ADD: QueryFactory now sets the sequntial bind prefix
    • FIX: Fix line endings in queries to be sure tests will pass on windows and mac. Merge pull request #53 from ksimka/fix-tests-remove-line-endings: Fixed tests for windows.
    • Merge pull request #50 from auraphp/bindonjoin: Allow binding of values as part of join() methods.
    • Merge pull request #51 from auraphp/aliastracking: Add table-reference tracking to disallow duplicate references.
    • Merge pull request #52 from auraphp/bindsubselect. Bind Values From Sub-Selects.
    • DOC: Update documentation and support files.
    Source code(tar.gz)
    Source code(zip)
  • 2.2.0(Feb 12, 2015)

    To avoid mixing numbered and names placeholders, we now convert numbered ? placeholders in where() and having() to :# named placeholders. This is because PDO is really touchy about sequence numbers on ? placeholders. If we have bound values [:foo, :bar, ?, :baz], the ? placeholder is not number 1, it is number 3. As it is nigh impossible to keep track of the numbering when done out-of-order, we now do a braindead check on the where/having condition string to see if it has ? placholders, and replace them with named :# placeholders, where # is the current count of the $bind_values array.

    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Aug 24, 2014)

    • ADD: Select::fromRaw() to allow raw FROM clause strings.
    • CHG: In Select, quote the columns at build time, not add time.
    • CHG: In Select, retain columns keyed on their aliases (when given).
    • DOC: Updates to README and docblocks.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(Jun 9, 2014)

    Initial 2.0 stable release.

    • The package has been renamed from Sql_Query to SqlQuery, in line with the new Aura naming standards.
    • Now compatible with PHP 5.3!
    • Refactored traits into interfaces (thanks @mindplay-dk).
    • Refactored the internal build process (thanks again @mindplay-dk).
    • Added Select::leftJoin()/innerJoin() methods (thanks @stanlemon).
    • Methods bindValue() and bindValues() are now fluent (thanks @harikt).
    • Select now throws an exception when there are no columns selected.
    • In joins, the condition type (ON or USING) may now be part of the condition.
    • Extracted new class, Quoter, for quoting identifer names.
    • Extracted new class, AbstractDmlQuery, for Insert/Update/Delete queries.
    • Select::cols() now accepts colname => alias pairs mixed in with sequential colname values.
    • Added functionality to map last-insert-id names to alternative sequence names, esp. for Postgres and inherited/extended tables. Cf. QueryFactory::setLastInsertIdNames() and Insert::setLastInsertIdNames().
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-beta1(Jan 7, 2014)

Owner
Aura for PHP
High-quality, well-tested, standards-compliant, decoupled libraries that can be used in any codebase.
Aura for PHP
A simple and extensible fixture loader for PHP 7.3+, supporting SQLite and MySQL

Flowder Flowder is a (really) simple fixture loader for PHP 7.3+, supporting SQLite and MySQL. Using Flowder in PHP 7.2 or below? Try version 1 instea

Joe Haines 6 Jan 17, 2021
phpMyFAQ - Open Source FAQ web application for PHP and MySQL, PostgreSQL and other databases

phpMyFAQ 3.1 What is phpMyFAQ? phpMyFAQ is a multilingual, completely database-driven FAQ-system. It supports various databases to store all data, PHP

Thorsten Rinne 547 Dec 27, 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
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 618 Dec 30, 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 162 Dec 19, 2022
A simple library to access and manipulate database records. Built on top of Dibi and hardwired for PostgreSQL.

grifart/tables A simple library to access and manipulate database records. Built on top of Dibi and hardwired for PostgreSQL. This library is develope

GRIFART 5 Nov 11, 2022
A validating SQL lexer and parser with a focus on MySQL dialect.

SQL Parser A validating SQL lexer and parser with a focus on MySQL dialect. Code status Installation Please use Composer to install: composer require

phpMyAdmin 368 Dec 27, 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 18 Dec 10, 2022
The Enobrev\ORM library is a small framework of classes meant to be used for simply mapping a mysql database to PHP classes, and for creating simply SQL statements using those classes.

The Enobrev\ORM library is a small framework of classes meant to be used for simply mapping a mysql database to PHP classes, and for creating simply SQL statements using those classes.

Mark Armendariz 0 Jan 7, 2022
FlatsApp using Laravel 8 with SQLite

The FlatsApp This Application Stacks using Laravel 8 with MySQL. Installation To get up and running of this Application please make sure you already h

ivandjoh 4 Nov 17, 2022
Feather - a highly performant SQLite Cache Driver for Kirby 3

?? Kirby3 SQLite Cache-Driver Feather - a highly performant SQLite Cache Driver for Kirby 3 Commerical Usage Support open source! This plugin is free

Bruno Meilick 1 Dec 15, 2021
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
PHP Object Model Manager for Postgresql

POMM: The PHP Object Model Manager for Postgresql Note This is the 1,x version of Pomm. This package is not maintained anymore, the stable Pomm 2.0 is

Grégoire HUBERT 161 Oct 17, 2022
🔌 A Doctrine DBAL Driver implementation on top of Swoole Coroutine PostgreSQL extension

Swoole Coroutine PostgreSQL Doctrine DBAL Driver A Doctrine\DBAL\Driver implementation on top of Swoole\Coroutine\PostgreSQL. Getting started Install

Leo Cavalcante 19 Nov 25, 2022
Support for many missing PostgreSQL specific features

Laravel supports many different databases and therefore has to limit itself to the lowest common denominator of all databases. PostgreSQL, however, of

Tobias Petry 359 Jan 3, 2023
Laravel Thermite is an extended PostgreSQL Laravel database driver to connect to a CockroachDB cluster.

Laravel Thermite Laravel Thermite is an extended PostgreSQL Laravel database driver to connect to a CockroachDB cluster. ?? Supporting If you are usin

Renoki Co. 9 Nov 15, 2022
PostgreSQL enhancements for Doctrine

PostgreSQL enhancements for Doctrine. Provides support for advanced data types (json, jssnb, arrays), text search, array operators and jsonb specific functions.

Martin Georgiev 258 Dec 31, 2022
Orm is a simple database abstraction layer that supports postgresql.

Orm What is it Orm is a simple database abstraction layer that supports postgresql. Welcome to join us or star us for encouragement. Requires php 8.1

null 2 Sep 28, 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.

null 2 Mar 7, 2022