flush
[mdref/mdref-pq-gateway] / pq-gateway / pq / Gateway / Table / Relations / getReference.md
1 # stdClass pq\Gateway\Table\Relations::getReference(string $to)
2
3 Retrieve the foreign key of the table to another table.
4
5 ## Params:
6
7 * string $to
8 The table name referenced by a foreign key of the table.
9
10 ## Returns:
11
12 * stdClass, the table relation.
13 * NULL, if the tables are not related.
14
15 ## Example:
16
17 <?php
18
19 use pq\Gateway\Table;
20
21 $email = new Table("account_email");
22 $relation = new Table\Relations($email);
23 $account = $relation->getReference("account");
24
25 var_dump($account);
26
27 ?>
28
29 Yields:
30
31 object(stdClass)#13 (1) {
32 ["account_email"]=>
33 object(stdClass)#14 (4) {
34 ["foreignTable"]=>
35 string(13) "account_email"
36 ["foreignColumn"]=>
37 string(10) "account_id"
38 ["referencedTable"]=>
39 string(7) "account"
40 ["referencedColumn"]=>
41 string(2) "id"
42 }
43 }
44