Skip to content

Releases: rkrx/php-mysql-query-builder

x=NULL-Values are now projected as ISNULL(x) in some cases

10 Sep 15:24

Choose a tag to compare

NULL-Values used in conjunction with Select::where and Select::having when conditions are used as a key-value-array are now projected with ISNULL instead of field=NULL.

$str = $select
->field('a')
->from('t', 'test')
->where(['field' => null])
->asString();

will result in

SELECT
    a
FROM
    test t
WHERE
    (ISNULL(`field`))

Fixed type-hinting in various cases

07 Mar 12:32

Choose a tag to compare

Pre-release
0.1.53.2

- Fixed type-hinting in various cases

Fixed various issues reported by phpstan

05 Mar 19:41

Choose a tag to compare

  • Fixed various issues reported by phpstan
  • Integrated phpstan into the travis-workflow

Allow MySQL::quoteExpression to take less arguments than necessary

25 Feb 18:46

Choose a tag to compare

Allow MySQL::quoteExpression to take less arguments than necessary. If more arguments are required than available, the last given argument is used to fill the remaining placeholders.

Enhanced MySQLExceptionInterpreter::throwMoreConcreteException

05 Feb 12:49

Choose a tag to compare

  • MySQLExceptionInterpreter::throwMoreConcreteException now handles SQL-Error-Codes 1452

Enhanced MySQLExceptionInterpreter::throwMoreConcreteException

05 Feb 12:22

Choose a tag to compare

  • MySQLExceptionInterpreter::throwMoreConcreteException now handles SQL-Error-Codes 1216, 1217

Enhanced MySQLExceptionInterpreter::throwMoreConcreteException

05 Feb 10:11

Choose a tag to compare

  • MySQLExceptionInterpreter::throwMoreConcreteException now handles SQL-Error-Codes 1022, 1169, 1586

Support simple arrays like [1, 2, 3, 4, 5] as table-names which will result in a UNION-chain-subquery

29 Nov 10:46

Choose a tag to compare

Example:

$select
->field('a.value')
->from('a', range(1, 9))
->asString();
SELECT
	a.value
FROM
	(SELECT '1' AS `value`
	UNION
	SELECT '2' AS `value`
	UNION
	SELECT '3' AS `value`
	UNION
	SELECT '4' AS `value`
	UNION
	SELECT '5' AS `value`
	UNION
	SELECT '6' AS `value`
	UNION
	SELECT '7' AS `value`
	UNION
	SELECT '8' AS `value`
	UNION
	SELECT '9' AS `value`) a

Now PHP will moan about non-optional parameters of virtual tables

02 Nov 13:48

Choose a tag to compare

When using parameterized virtual tables without parameters, PHP will now moan about the missing parameter when not defined as optional.

Added support for parameterized virtual tables

02 Nov 13:43

Choose a tag to compare

Parameterized virtual tables

When you need parameterized sub-selects, you can use the Helperclass Kir\MySQL\Tools\VirtualTable to add parameters to a table-name:

Definition:

use Kir\MySQL\Databases\MySQL;

$db = new MySQL($pdo);

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

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

// Lazy evaluated; parameterized
$db->getVirtualTables()->add('virt_table2', function (array $args) {
	return $db->select()
	->field('a.field1')
	->from('a', 'tableA')
	->where(new DBExprFilter('a.active=?', $args, 'active'));
});

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', new VirtualTable('virt_table2', ['active' => 1]), 'vt2.field2=t.field2');