68134b72e517aa5f1daa7f578d9d9fb357b8b01f
[mdref/mdref-pq-gateway] / pq-gateway / pq / Gateway / Table / of.md
1 # mixed pq\Gateway\Table::of(pq\Gateway\Row $foreign[, string $name = NULL[, string $order = NULL[, int $limit = 0[, int $offset = 0]]]])
2
3 Find rows in table by foreign key.
4 See pq\Gateway\Table::find(), pq\Gateway\Table::by() and pq\Gateway\Row::allOf().
5
6 ## Params:
7
8 * pq\Gateway\Row $row
9 A row of a table referencing this table through a foreign key.
10 * Optional string $name = NULL
11 The identifying name of the relation.
12 * Optional string $order = NULL
13 Sorting clause.
14 * Optional int $limit = 0
15 Row count limit.
16 * Optional int $offset = 0
17 Row count offset.
18
19 ## Returns:
20
21 * a [deferred promise of React/Promise](https://github.com/reactphp/promise#deferred-1), when using pq\Query\AsyncExecutor, the asynchronous executor.
22 Else:
23 * pq\Result, if pq\Result::$status != pq\Result::TUPLES_OK.
24 * pq\Result, if the rowset prototype pq\Gateway\Table::$rowset is empty.
25 * pq\Gateway\Rowset, an instance of the rowset prototype.
26
27 ## Example:
28
29 <?php
30
31 use pq\Gateway\Table;
32
33 $accounts = new Table("account");
34 $account = $accounts->find(["id=" => 1])->current();
35
36 $account_emails = new Table("account_emails");
37 $emails = $account_emails->of($account);
38
39 ?>