1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-07 14:46:50 +02:00

Result: added getColumnCount()

This commit is contained in:
David Grudl
2018-05-04 22:32:45 +02:00
parent 3660f26e03
commit 2848c965f9
2 changed files with 17 additions and 2 deletions

View File

@@ -134,6 +134,16 @@ class Result implements IDataSource
}
/**
* Returns the number of columns in a result set.
* @return int
*/
final public function getColumnCount()
{
return count($this->types);
}
/********************* fetching rows ****************d*g**/

View File

@@ -11,12 +11,17 @@ require __DIR__ . '/bootstrap.php';
$conn = new Dibi\Connection($config);
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
$info = $conn->query('
$res = $conn->query('
SELECT products.product_id, orders.order_id, customers.name, products.product_id + 1 AS [xXx]
FROM ([products]
INNER JOIN [orders] ON [products.product_id] = [orders.product_id])
INNER JOIN [customers] ON [orders.customer_id] = [customers.customer_id]
')->getInfo();
');
$info = $res->getInfo();
Assert::same(4, $res->getColumnCount());
Assert::same(