/** * 格式化为字符串 * * @param QDB_Adapter_Abstract $conn * @param string $table_name * @param array $mapping * @param callback $callback * * @return string */ function formatToString($conn, $table_name = null, array $mapping = null, $callback = null) { if (!is_array($mapping)) { $mapping = array(); } return $conn->qsql($this->_expr, $table_name, $mapping, $callback); }
/** * 添加一个集合查询 * * @param int $type * @param string|QDB_Expr $field * @param string $alias * * @return QDB_Select */ protected function _addAggregate($type, $field, $alias) { $this->_parts[self::COLUMNS] = array(); $this->_query_params[self::RECURSION] = 0; if ($field instanceof QDB_Expr) { $field = $field->formatToString($this->_conn, $this->_getCurrentTableName(), $this->_columns_mapping); } else { if (isset($this->_columns_mapping[$field])) { $field = $this->_columns_mapping[$field]; } $field = $this->_conn->qsql($field, $this->_getCurrentTableName(), $this->_columns_mapping); $field = "{$type}({$field})"; } $this->_parts[self::AGGREGATE][] = array($type, $field, $alias); $this->_query_params[self::AS_ARRAY] = true; return $this; }