mirror of
https://github.com/dg/dibi.git
synced 2025-08-19 04:11:44 +02:00
Connection::query() and Fluent::execute() always return Result, not the number of affected rows (BC break)
This commit is contained in:
@@ -20,18 +20,22 @@ $conn->query('INSERT INTO products', [
|
||||
Assert::same(1, $conn->getAffectedRows());
|
||||
|
||||
|
||||
$conn->query('UPDATE products SET title="xxx" WHERE product_id > 100');
|
||||
$res = $conn->query('UPDATE products SET title="xxx" WHERE product_id > 100');
|
||||
Assert::same(0, $conn->getAffectedRows());
|
||||
Assert::same(0, $res->getRowCount());
|
||||
|
||||
|
||||
$conn->query('UPDATE products SET title="xxx"');
|
||||
$res = $conn->query('UPDATE products SET title="xxx"');
|
||||
Assert::same(4, $conn->getAffectedRows());
|
||||
Assert::same(4, $res->getRowCount());
|
||||
|
||||
|
||||
$conn->query('DELETE FROM orders');
|
||||
$conn->query('DELETE FROM products WHERE product_id > 100');
|
||||
$res = $conn->query('DELETE FROM products WHERE product_id > 100');
|
||||
Assert::same(0, $conn->getAffectedRows());
|
||||
Assert::same(0, $res->getRowCount());
|
||||
|
||||
|
||||
$conn->query('DELETE FROM products WHERE product_id < 3');
|
||||
$res = $conn->query('DELETE FROM products WHERE product_id < 3');
|
||||
Assert::same(2, $conn->getAffectedRows());
|
||||
Assert::same(2, $res->getRowCount());
|
||||
|
@@ -54,4 +54,6 @@ if (!in_array($config['system'], ['odbc', 'sqlsrv'], true)) {
|
||||
|
||||
// affected rows
|
||||
$res = $conn->update('products', ['title' => 'new'])->execute();
|
||||
Assert::same(3, $res);
|
||||
Assert::same(3, $res->getRowCount());
|
||||
Assert::same(0, $res->getColumnCount());
|
||||
Assert::same(3, $conn->getAffectedRows());
|
||||
|
Reference in New Issue
Block a user