| @@ 89-108 (lines=20) @@ | ||
| 86 | * @param string $table |
|
| 87 | * @return int|null |
|
| 88 | */ |
|
| 89 | public function getTableOid($schema, $table) |
|
| 90 | { |
|
| 91 | $sql = <<<SQL |
|
| 92 | select |
|
| 93 | c.oid as oid |
|
| 94 | from |
|
| 95 | pg_catalog.pg_class c |
|
| 96 | left join pg_catalog.pg_namespace n on n.oid = c.relnamespace |
|
| 97 | where |
|
| 98 | :condition |
|
| 99 | SQL; |
|
| 100 | ||
| 101 | $where = Where::create('n.nspname = $*', [$schema]) |
|
| 102 | ->andWhere('c.relname = $*', [$table]) |
|
| 103 | ; |
|
| 104 | ||
| 105 | $iterator = $this->executeSql($sql, $where); |
|
| 106 | ||
| 107 | return $iterator->isEmpty() ? null : $iterator->current()['oid']; |
|
| 108 | } |
|
| 109 | ||
| 110 | /** |
|
| 111 | * getTableFieldInformation |
|
| @@ 165-183 (lines=19) @@ | ||
| 162 | * @param Where $where optional where clause. |
|
| 163 | * @return int|null |
|
| 164 | */ |
|
| 165 | public function getSchemaOid($schema, Where $where = null) |
|
| 166 | { |
|
| 167 | $condition = |
|
| 168 | Where::create("s.nspname = $*", [$schema]) |
|
| 169 | ->andWhere($where) |
|
| 170 | ; |
|
| 171 | $sql = <<<SQL |
|
| 172 | select |
|
| 173 | s.oid as oid |
|
| 174 | from |
|
| 175 | pg_catalog.pg_namespace s |
|
| 176 | where |
|
| 177 | :condition |
|
| 178 | SQL; |
|
| 179 | ||
| 180 | $iterator = $this->executeSql($sql, $condition); |
|
| 181 | ||
| 182 | return $iterator->isEmpty() ? null : $iterator->current()['oid']; |
|
| 183 | } |
|
| 184 | ||
| 185 | /** |
|
| 186 | * getPrimaryKey |
|