1
0
mirror of https://github.com/dg/dibi.git synced 2025-02-24 10:53:17 +01:00
php-dibi/tests/dibi/Connection.affectedRows.phpt

38 lines
800 B
Plaintext
Raw Normal View History

2015-01-12 05:33:41 +01:00
<?php
/**
* @dataProvider ../databases.ini
*/
2017-06-09 22:20:47 +02:00
declare(strict_types=1);
2015-01-12 05:33:41 +01:00
use Tester\Assert;
require __DIR__ . '/bootstrap.php';
$conn = new Dibi\Connection($config);
2015-01-12 05:33:41 +01:00
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
2015-10-06 01:39:01 +02:00
$conn->query('INSERT INTO products', [
2015-01-12 05:33:41 +01:00
'title' => 'Test product',
2015-10-06 01:39:01 +02:00
]);
2015-01-12 05:33:41 +01:00
Assert::same(1, $conn->getAffectedRows());
$conn->query('UPDATE products SET title="xxx" WHERE product_id > 100');
Assert::same(0, $conn->getAffectedRows());
$conn->query('UPDATE products SET title="xxx"');
Assert::same(4, $conn->getAffectedRows());
$conn->query('DELETE FROM orders');
$conn->query('DELETE FROM products WHERE product_id > 100');
Assert::same(0, $conn->getAffectedRows());
$conn->query('DELETE FROM products WHERE product_id < 3');
Assert::same(2, $conn->getAffectedRows());