flush
[mdref/mdref-pq-gateway] / pq-gateway / pq / Gateway / Table / with.md
1 # mixed pq\Gateway\Table::with(array $relations[, array $where = NULL[, string $order = NULL[, int $limit = 0[, int $offset = 0]]]])
2
3 Find rows dependent on other rows by foreign keys.
4 See pq\Gateway\Table::of(), pq\Gateway\Table::by() and pq\Gateway\Table::find().
5
6 ## Params:
7
8 * array $relations
9 list of stdClass instances representing relations to join for the query; see pq\Gateway\Table::getRelations().
10 * Optional array $where = NULL
11 Additional lookup criteria.
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 $emails = new Table("account_email");
34 $accounts = new Table("account");
35 $notifications = new Table("notification");
36
37 $relations = [
38 $emails->getRelations("account")->account_email,
39 $notifications->getRelations("email")->notification
40 ];
41
42 $bouncers = $accounts->with($relations, ["bounces>" => 3]);
43
44 ?>