|
@@ -158,59 +158,4 @@ class Dm extends PDOConnection
|
|
|
$this->initConnect(true);
|
|
|
$this->linkID->exec("XA ROLLBACK '$xid'");
|
|
|
}
|
|
|
- /**
|
|
|
- * 查找记录
|
|
|
- * @access public
|
|
|
- * @param Query $query 查询对象
|
|
|
- * @return array|\PDOStatement|string
|
|
|
- * @throws DbException
|
|
|
- * @throws ModelNotFoundException
|
|
|
- * @throws DataNotFoundException
|
|
|
- */
|
|
|
- public function select(BaseQuery $query): array
|
|
|
- {
|
|
|
- // 分析查询表达式
|
|
|
- $options = $query->getOptions();
|
|
|
-
|
|
|
- if (empty($options['fetch_sql']) && !empty($options['cache'])) {
|
|
|
- $resultSet = $this->getCacheData($query, $options['cache'], null, $key);
|
|
|
-
|
|
|
- if (false !== $resultSet) {
|
|
|
- return $resultSet;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 生成查询SQL
|
|
|
- $sql = $this->builder->select($query);
|
|
|
-
|
|
|
- $query->removeOption('limit');
|
|
|
-
|
|
|
- $bind = $query->getBind();
|
|
|
-
|
|
|
- if (!empty($options['fetch_sql'])) {
|
|
|
- // 获取实际执行的SQL语句
|
|
|
- return $this->getRealSql($sql, $bind);
|
|
|
- }
|
|
|
-
|
|
|
- $resultSet = $query->trigger('before_select');
|
|
|
-
|
|
|
- if (!$resultSet) {
|
|
|
- // 执行查询操作
|
|
|
- $resultSet = $this->query($sql, $bind, $options['master'], $options['fetch_pdo']);
|
|
|
- if ($resultSet instanceof \PDOStatement) {
|
|
|
- // 返回PDOStatement对象
|
|
|
- return $resultSet;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $resultSet = $this->formatFieldUpper($resultSet, $options['field']);
|
|
|
- $resultSet = $this->formatColumnFieldType($options['field'], $resultSet);
|
|
|
-
|
|
|
- if (!empty($options['cache']) && false !== $resultSet) {
|
|
|
- // 缓存数据集
|
|
|
- $this->cacheData($key, $resultSet, $options['cache']);
|
|
|
- }
|
|
|
-
|
|
|
- return $resultSet;
|
|
|
- }
|
|
|
}
|