1
0
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:
David Grudl
2018-05-02 18:39:25 +02:00
parent e291d4d825
commit 8dff5b5b3c
7 changed files with 92 additions and 23 deletions

View File

@@ -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());

View File

@@ -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());