Пример #1
0
 /**
  * @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);
         });
     }
 }
Пример #2
0
 /**
  * @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);
         });
     }
 }
Пример #3
0
 /**
  * @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);
         });
     }
 }