mirror of
https://github.com/dg/dibi.git
synced 2025-08-18 03:41:30 +02:00
used PHP 5.4 syntax
This commit is contained in:
@@ -29,31 +29,31 @@ Assert::equal('Chair', $res->fetchSingle());
|
||||
|
||||
// fetch complete result set
|
||||
$res = $conn->select('*')->from('products')->orderBy('product_id');
|
||||
Assert::equal(array(
|
||||
new DibiRow(array('product_id' => num(1), 'title' => 'Chair')),
|
||||
new DibiRow(array('product_id' => num(2), 'title' => 'Table')),
|
||||
new DibiRow(array('product_id' => num(3), 'title' => 'Computer')),
|
||||
), $res->fetchAll());
|
||||
Assert::equal([
|
||||
new DibiRow(['product_id' => num(1), 'title' => 'Chair']),
|
||||
new DibiRow(['product_id' => num(2), 'title' => 'Table']),
|
||||
new DibiRow(['product_id' => num(3), 'title' => 'Computer']),
|
||||
], $res->fetchAll());
|
||||
|
||||
|
||||
// more complex association array
|
||||
if ($config['system'] !== 'odbc') {
|
||||
$res = $conn->select(array('products.title' => 'title', 'customers.name' => 'name'))->select('orders.amount')->as('amount')
|
||||
$res = $conn->select(['products.title' => 'title', 'customers.name' => 'name'])->select('orders.amount')->as('amount')
|
||||
->from('products')
|
||||
->innerJoin('orders')->using('(product_id)')
|
||||
->innerJoin('customers')->using('([customer_id])')
|
||||
->orderBy('order_id');
|
||||
|
||||
Assert::equal(array(
|
||||
'Arnold Rimmer' => array(
|
||||
'Chair' => new DibiRow(array('title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0))),
|
||||
'Computer' => new DibiRow(array('title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0))),
|
||||
),
|
||||
'Dave Lister' => array(
|
||||
'Table' => new DibiRow(array('title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0))),
|
||||
),
|
||||
'Kristine Kochanski' => array(
|
||||
'Computer' => new DibiRow(array('title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0))),
|
||||
),
|
||||
), $res->fetchAssoc('name,title'));
|
||||
Assert::equal([
|
||||
'Arnold Rimmer' => [
|
||||
'Chair' => new DibiRow(['title' => 'Chair', 'name' => 'Arnold Rimmer', 'amount' => num(7.0)]),
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Arnold Rimmer', 'amount' => num(2.0)]),
|
||||
],
|
||||
'Dave Lister' => [
|
||||
'Table' => new DibiRow(['title' => 'Table', 'name' => 'Dave Lister', 'amount' => num(3.0)]),
|
||||
],
|
||||
'Kristine Kochanski' => [
|
||||
'Computer' => new DibiRow(['title' => 'Computer', 'name' => 'Kristine Kochanski', 'amount' => num(5.0)]),
|
||||
],
|
||||
], $res->fetchAssoc('name,title'));
|
||||
}
|
||||
|
Reference in New Issue
Block a user