Skip to content

Commit 045a925

Browse files
committed
Fixing up examples
1 parent bf18d70 commit 045a925

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

scripts/examples.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,35 @@
3737
echo "{$customer->first_name} {$customer->last_name}, {$customer->job_title}\n";
3838
}
3939

40-
$customerTable->addOrderBy('last_name');
40+
$customerTable->setOrderBy('last_name');
4141
echo "\n\nCustomers in last_name order:\n\n";
4242
foreach ($customerTable->getRecordCursor() as $customer)
4343
{
4444
echo "{$customer->first_name} {$customer->last_name}, {$customer->job_title}\n";
4545
}
4646

47-
$customerTable->addOrderBy('last_name', 'desc');
47+
$customerTable->setOrderBy('last_name', 'desc');
4848
$customerTable->setLimit(10);
4949

50-
echo "\n\nLast 10 Customers in last_name order:\n\n";
50+
echo "\n\nLast 10 Customers in last_name order descending:\n\n";
5151
foreach ($customerTable->getRecordCursor() as $customer)
5252
{
5353
echo "{$customer->first_name} {$customer->last_name}, {$customer->job_title}\n";
5454
}
5555

56-
$customerTable->setLimit(0);
57-
$customerTable->addGroupBy('company');
58-
$customerTable->addSelect(new \PHPFUI\ORM\Literal('count(*)'), 'count');
59-
$customerTable->addSelect('company');
60-
$customerTable->setOrderBy('company');
61-
echo "\n\nCount of Customers by company:\n\n";
56+
$orderTable = new \Tests\App\Table\Order();
57+
$orderTable->addJoin('customer');
58+
$orderTable->addGroupBy('customer.customer_id');
59+
$orderTable->addSelect(new \PHPFUI\ORM\Literal('count("order_id")'), 'count');
60+
$orderTable->addSelect('company');
61+
$orderTable->setOrderBy('company');
62+
echo "\n\nCount of Orders by customer:\n\n";
6263

63-
foreach ($customerTable->getDataObjectCursor() as $customer)
64+
foreach ($orderTable->getDataObjectCursor() as $customer)
6465
{
6566
echo "{$customer->company}: {$customer->count}\n";
6667
}
6768

68-
6969
$orderTable = new \Tests\App\Table\Order();
7070
// addJoin defaults to using the primary key of the related table
7171
$orderTable->addJoin('customer');

0 commit comments

Comments
 (0)