mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 14:16:39 +02:00
Result: added getColumnCount()
This commit is contained in:
@@ -127,6 +127,15 @@ class Result implements IDataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of columns in a result set.
|
||||||
|
*/
|
||||||
|
final public function getColumnCount(): int
|
||||||
|
{
|
||||||
|
return count($this->types);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************* fetching rows ****************d*g**/
|
/********************* fetching rows ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
@@ -13,12 +13,17 @@ require __DIR__ . '/bootstrap.php';
|
|||||||
$conn = new Dibi\Connection($config);
|
$conn = new Dibi\Connection($config);
|
||||||
$conn->loadFile(__DIR__ . "/data/$config[system].sql");
|
$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]
|
SELECT products.product_id, orders.order_id, customers.name, products.product_id + 1 AS [xXx]
|
||||||
FROM ([products]
|
FROM ([products]
|
||||||
INNER JOIN [orders] ON [products.product_id] = [orders.product_id])
|
INNER JOIN [orders] ON [products.product_id] = [orders.product_id])
|
||||||
INNER JOIN [customers] ON [orders.customer_id] = [customers.customer_id]
|
INNER JOIN [customers] ON [orders.customer_id] = [customers.customer_id]
|
||||||
')->getInfo();
|
');
|
||||||
|
|
||||||
|
$info = $res->getInfo();
|
||||||
|
|
||||||
|
|
||||||
|
Assert::same(4, $res->getColumnCount());
|
||||||
|
|
||||||
|
|
||||||
Assert::same(
|
Assert::same(
|
||||||
|
Reference in New Issue
Block a user