*/
public static $defaultResolver;
+ /**
+ * @var \pq\Gateway\Table\CacheInterface
+ */
+ public static $defaultMetadataCache;
+
/**
* @var \pq\Connection
*/
*/
protected $relations;
+ /**
+ * @var \pq\Gateway\Table\CacheInterface
+ */
+ protected $metadataCache;
+
/**
* @param string $table
* @return \pq\Gateway\Table
$this->conn = $conn ?: static::$defaultConnection ?: new \pq\Connection;
}
+ /**
+ * Get the complete PostgreSQL connection string
+ * @return string
+ */
+ function __toString() {
+ return sprintf("postgresql://%s:%s@%s:%d/%s?%s#%s",
+ $this->conn->user,
+ $this->conn->pass,
+ $this->conn->host,
+ $this->conn->port,
+ $this->conn->db,
+ $this->conn->options,
+ $this->getName()
+ );
+ }
+
/**
* Set the rowset prototype
* @param mixed $rowset
return $this->exec;
}
+ /**
+ * Get the metadata cache
+ * @return \pq\Gateway\Table\CacheInterface
+ */
+ function getMetadataCache() {
+ if (!isset($this->metadatCache)) {
+ $this->metadataCache = static::$defaultMetadataCache ?: new Table\StaticCache;
+ }
+ return $this->metadataCache;
+ }
+
+ /**
+ * Set the metadata cache
+ * @param \pq\Gateway\Table\CacheInterface $cache
+ */
+ function setMetadataCache(Table\CacheInterface $cache) {
+ $this->metadataCache = $cache;
+ return $this;
+ }
+
/**
* Get foreign key relations
* @param string $to fkey
* @return mixed
*/
protected function execute(QueryWriter $query) {
- echo $query,"\n",json_encode($query->getParams()),"\n";
return $this->getQueryExecutor()->execute($query, array($this, "onResult"));
}