/** * @param \pq\Gateway\Table $table */ function __construct(Table $table) { $cache = $table->getMetadataCache(); if (!($this->columns = $cache->get("{$table}:identity"))) { $table->getQueryExecutor()->execute(new \pq\Query\Writer(IDENTITY_SQL, array($table->getName())), function ($result) use($table, $cache) { $this->columns = array_map("current", $result->fetchAll(\pq\Result::FETCH_ARRAY)); $cache->set("{$table}:identity", $this->columns); }); } }
/** * @param \pq\Gateway\Table $table */ function __construct(Table $table) { $cache = $table->getMetadataCache(); if (!($this->columns = $cache->get("{$table}:attributes"))) { $table->getQueryExecutor()->execute(new \pq\Query\Writer(ATTRIBUTES_SQL, array($table->getName())), function ($result) use($table, $cache) { foreach ($result->fetchAll(\pq\Result::FETCH_OBJECT) as $c) { $this->columns[$c->index] = $this->columns[$c->name] = $c; } $cache->set("{$table}:attributes", $this->columns); }); } }
/** * @param \pq\Gateway\Table $table */ function __construct(Table $table) { $cache = $table->getMetadataCache(); if (!($this->references = $cache->get("{$table}:relations"))) { $table->getQueryExecutor()->execute(new \pq\Query\Writer(RELATION_SQL, array($table->getName())), function ($result) use($table, $cache) { $rel = $result->map([1, 2], null, \pq\Result::FETCH_ASSOC); foreach ($rel as $ref) { foreach ($ref as $table => $key) { $reference = new Reference($key); $this->references[$table][$reference->name] = $reference; } } $cache->set("{$table}:relations", $this->references); }); } }