Skip to content

Releases: rkrx/php-mysql-query-builder

Fixed type-hinting in various cases

07 Mar 12:32
Compare
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
Compare
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
Compare
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
Compare
Choose a tag to compare
  • MySQLExceptionInterpreter::throwMoreConcreteException now handles SQL-Error-Codes 1452

Enhanced MySQLExceptionInterpreter::throwMoreConcreteException

05 Feb 12:22
Compare
Choose a tag to compare
  • MySQLExceptionInterpreter::throwMoreConcreteException now handles SQL-Error-Codes 1216, 1217

Enhanced MySQLExceptionInterpreter::throwMoreConcreteException

05 Feb 10:11
Compare
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
Compare
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
Compare
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
Compare
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');

The definition of a virtual table can now be set as a closure

02 Nov 11:13
Compare
Choose a tag to compare

The definition of a virtual table can now be set as a closure, which is lazy evaluated:

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
$db->getVirtualTables()->add('virt_table2', function () {
	return $db->select()
	->field('a.field1')
	->from('a', 'tableA');
});
$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');