1 # bool pq\Gateway\Table::hasRelation(string $name[, string $table = NULL])
3 Check whether a relation to another table exists with the specified name.
4 See pq\Gateway\Table\Relations
7 The relation name is the column name of the foreign key with the column name of the referenced column cut off the end.
12 The name of the relation.
13 * Optional string $table = NULL
14 The bare table name, if the relation has another name (e.g. because of multiple foreign keys to the same table).
18 * bool, whether the specified relation exists.
26 $conn = new pq\Connection;
28 drop table if exists account cascade;
29 drop table if exists email cascade;
30 drop table if exists reftable cascade;
32 create table account (
37 id serial primary key,
38 account_id integer references account(id),
42 create table reftable (
43 id serial primary key,
44 my_account integer references account(id),
45 account_id integer references account(id),
46 second_account_id integer references account(id),
47 email integer references email(id)
51 $fgn_table = new Table("reftable");
52 var_dump($fgn_table->hasRelation("my_account"));