/** * Instantiate class * @param $db object * @param $table string * @param $fields array|string * @param $ttl int **/ function __construct(\DB\SQL $db, $table, $fields = NULL, $ttl = 60) { $this->db = $db; $this->engine = $db->driver(); if ($this->engine == 'oci') { $table = strtoupper($table); } $this->source = $table; $this->table = $this->db->quotekey($table); $this->fields = $db->schema($table, $fields, $ttl); $this->reset(); }
/** Instantiate class @param $db object @param $table string @param $ttl int **/ function __construct(\DB\SQL $db, $table, $ttl = 60) { $this->db = $db; $this->engine = $db->driver(); $this->table = $table; $this->fields = $db->schema($table, $ttl); $this->reset(); }
/** * Instantiate class * @param $db object * @param $table string|array * @param $fields array|string * @param $ttl int **/ function __construct(\DB\SQL $db, $table, $fields = NULL, $ttl = 60) { $this->db = $db; $this->engine = $db->driver(); $this->table = null; $this->fields = array(); if (null != $table) { // QiangYu 支持多个表取得 Schema,注意不同的表之间不要取相同名字的列名 if (is_array($table)) { $this->fields = array(); foreach ($table as $oneTable) { $this->fields = array_merge($this->fields, $db->schema($oneTable, $fields, $ttl)); } } else { // 单表查询 $table = trim($table); $this->table = $table; if (strstr($table, ' ')) { // QiangYu 表名不应该有空格,如果有空格,则为特殊的查询,比如 tableA left join tableB ,就不能做任何处理 } else { if ($this->engine == 'oci') { $table = strtoupper($table); } $this->source = $table; $this->table = $this->db->quotekey($table); $this->fields = $db->schema($table, $fields, $ttl); } } } $this->reset(); }