Skip to content

Releases: rkrx/php-mysql-query-builder

Added Support for Virtual Tables

02 Nov 10:56
Compare
Choose a tag to compare
Pre-release

You can now use virtual tables, which are basically just sub-selects referenced by a identifier.

First define virtual tables somewhere in your bootstrap:

use Kir\MySQL\Databases\MySQL;

$db = new MySQL($pdo);

$vt1 = $db->select()
->field('a.field1')
->from('a', 'tableA');

$vt2 = $db->select()
->field('a.field1')
->from('a', 'tableA');

$db->getVirtualTables()->add('virt_table1', $vt1);
$db->getVirtualTables()->add('virt_table2', $vt2);

Then use it as needed:

$query = $db->select()
->field('t.field1')
->field('vt1.fieldN')
->field('vt2.fieldN')
->from('t', 'test')
->joinInner('vt1', 'virt_table1', 'vt1.field1=t.field1')
->joinInner('vt2', 'virt_table2', 'vt2.field2=t.field2');

Fixed various problems introduced after last release

19 Sep 14:15
Compare
Choose a tag to compare
  • Fixed various problems with default parameters after last release
  • Fixed MySQL::dryRun where PHP7-\Errors caused rollbacks on transactions
  • Fixed MySQL::transaction where tries were not handled correctly

Fixed exception-handling and PHPDocs

18 Sep 09:06
Compare
Choose a tag to compare
Pre-release
  • Fixed Exception-Handling (Replaced \Exception with more appropriate \RuntimeException)
  • Fixed various PHPDocs

Various changes

16 Aug 09:36
Compare
Choose a tag to compare
Various changes Pre-release
Pre-release
  • Added $options as the second parameter to MySQL::__construct to specify global behavior
  • Added the ability to set user defined factories for the SIUD-Query-Builders
  • Added $options-Parameter 'select-options' > 'preserve-types-default'
  • Added $options-Parameter 'select-options' > 'fetch-object-class-default' for fetchObject*
  • Look at the README.md/initialization for more information

RunnableSelect::fetchObject*: Added default-value 'stdClass' for $className

16 Aug 09:01
Compare
Choose a tag to compare
  • RunnableSelect: Added default-value for $className to 'stdClass' for the methods fetchObject, fetchObjects and fetchObjectsLazy

PHPDoc now shows that WHERE and HAVING can handle arrays

13 Jun 19:55
Compare
Choose a tag to compare
  • Fixed PHPDoc for WHERE and HAVING to clarify the possibility to pass arrays as the first parameter

Added a way to define OrderBy by external parameters

23 Mar 00:17
Compare
Choose a tag to compare
  • Added OrderBySpecification
  • Added a way to define OrderBy by external parameters
$_GET['sort'] = [['field2', 'ASC'], ['field1', 'DESC'], ['field3' => 'ASC']];

echo $db
->field('t.field1')
->field('t.field2')
->from('t', 'test')
->orderBy(new DBExprOrderBySpec(['field1', 'field2' => 'REVERSE(t.field2)'], $_GET['sort']))
->asString();
SELECT
	t.field1,
	t.field2
FROM
	test t
ORDER BY
	REVERSE(t.field2) ASC,
	field1 DESC

Table-Names can now also be arrays

11 Nov 04:52
Compare
Choose a tag to compare
Pre-release

Now you can do this:

$select
->field('a.a')
->field('b.b')
->from('a', [['a' => 1, 'b' => 3], ['a' => 2, 'b' => 2], ['a' => 3, 'b' => 1]])
->joinInner('b', [['a' => 1, 'b' => 3], ['a' => 2, 'b' => 2], ['a' => 3, 'b' => 1]])

Which will result in this:

SELECT
    a.a,
    b.b
FROM
    (SELECT '1' AS `a`, '3' AS `b`
    UNION
    SELECT '2' AS `a`, '2' AS `b`
    UNION
    SELECT '3' AS `a`, '1' AS `b`) a
INNER JOIN
    (SELECT '1' AS `a`, '3' AS `b`
    UNION
    SELECT '2' AS `a`, '2' AS `b`
    UNION
    SELECT '3' AS `a`, '1' AS `b`) b

0.1.43.1

06 Jul 13:06
Compare
Choose a tag to compare
0.1.43.1 Pre-release
Pre-release
  • Fixed return of RunnableSelect::fetch when in object-mode

Added RunnableSelect::fetchObjects, ...::fetchObjectsLazy, ...::fetchObject

06 Jul 12:46
Compare
Choose a tag to compare
  • Added RunnableSelect::fetchObjects, RunnableSelect::fetchObjectsLazy, RunnableSelect::fetchObject