mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-10 16:42:48 +08:00
改进Query的参数绑定
This commit is contained in:
@@ -1599,13 +1599,15 @@ class Query
|
||||
$options = $this->parseExpress();
|
||||
// 生成SQL语句
|
||||
$sql = $this->builder()->insert($data, $options, $replace);
|
||||
// 获取参数绑定
|
||||
$bind = $this->getBind();
|
||||
if ($options['fetch_sql']) {
|
||||
// 获取实际执行的SQL语句
|
||||
return $this->connection->getRealSql($sql, $this->bind);
|
||||
return $this->connection->getRealSql($sql, $bind);
|
||||
}
|
||||
$sequence = $sequence ?: (isset($options['sequence']) ? $options['sequence'] : null);
|
||||
// 执行操作
|
||||
return $this->execute($sql, $this->getBind(), $getLastInsID, $sequence);
|
||||
return $this->execute($sql, $bind, $getLastInsID, $sequence);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1636,12 +1638,14 @@ class Query
|
||||
}
|
||||
// 生成SQL语句
|
||||
$sql = $this->builder()->insertAll($dataSet, $options);
|
||||
// 获取参数绑定
|
||||
$bind = $this->getBind();
|
||||
if ($options['fetch_sql']) {
|
||||
// 获取实际执行的SQL语句
|
||||
return $this->connection->getRealSql($sql, $this->bind);
|
||||
return $this->connection->getRealSql($sql, $bind);
|
||||
} else {
|
||||
// 执行操作
|
||||
return $this->execute($sql, $this->getBind());
|
||||
return $this->execute($sql, $bind);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1660,12 +1664,14 @@ class Query
|
||||
// 生成SQL语句
|
||||
$table = $this->parseSqlTable($table);
|
||||
$sql = $this->builder()->selectInsert($fields, $table, $options);
|
||||
// 获取参数绑定
|
||||
$bind = $this->getBind();
|
||||
if ($options['fetch_sql']) {
|
||||
// 获取实际执行的SQL语句
|
||||
return $this->connection->getRealSql($sql, $this->bind);
|
||||
return $this->connection->getRealSql($sql, $bind);
|
||||
} else {
|
||||
// 执行操作
|
||||
return $this->execute($sql, $this->getBind());
|
||||
return $this->execute($sql, $bind);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1708,9 +1714,11 @@ class Query
|
||||
}
|
||||
// 生成UPDATE SQL语句
|
||||
$sql = $this->builder()->update($data, $options);
|
||||
// 获取参数绑定
|
||||
$bind = $this->getBind();
|
||||
if ($options['fetch_sql']) {
|
||||
// 获取实际执行的SQL语句
|
||||
return $this->connection->getRealSql($sql, $this->bind);
|
||||
return $this->connection->getRealSql($sql, $bind);
|
||||
} else {
|
||||
// 检测缓存
|
||||
if (isset($key) && Cache::get($key)) {
|
||||
@@ -1718,7 +1726,7 @@ class Query
|
||||
Cache::rm($key);
|
||||
}
|
||||
// 执行操作
|
||||
return '' == $sql ? 0 : $this->execute($sql, $this->getBind());
|
||||
return '' == $sql ? 0 : $this->execute($sql, $bind);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1760,12 +1768,14 @@ class Query
|
||||
if (!$resultSet) {
|
||||
// 生成查询SQL
|
||||
$sql = $this->builder()->select($options);
|
||||
// 获取参数绑定
|
||||
$bind = $this->getBind();
|
||||
if ($options['fetch_sql']) {
|
||||
// 获取实际执行的SQL语句
|
||||
return $this->connection->getRealSql($sql, $this->bind);
|
||||
return $this->connection->getRealSql($sql, $bind);
|
||||
}
|
||||
// 执行查询操作
|
||||
$resultSet = $this->query($sql, $this->getBind(), $options['master'], $options['fetch_class']);
|
||||
$resultSet = $this->query($sql, $bind, $options['master'], $options['fetch_class']);
|
||||
|
||||
if ($resultSet instanceof \PDOStatement) {
|
||||
// 返回PDOStatement对象
|
||||
@@ -1845,12 +1855,14 @@ class Query
|
||||
if (!$result) {
|
||||
// 生成查询SQL
|
||||
$sql = $this->builder()->select($options);
|
||||
// 获取参数绑定
|
||||
$bind = $this->getBind();
|
||||
if ($options['fetch_sql']) {
|
||||
// 获取实际执行的SQL语句
|
||||
return $this->connection->getRealSql($sql, $this->bind);
|
||||
return $this->connection->getRealSql($sql, $bind);
|
||||
}
|
||||
// 执行查询
|
||||
$result = $this->query($sql, $this->getBind(), $options['master'], $options['fetch_class']);
|
||||
$result = $this->query($sql, $bind, $options['master'], $options['fetch_class']);
|
||||
|
||||
if ($result instanceof \PDOStatement) {
|
||||
// 返回PDOStatement对象
|
||||
@@ -2015,10 +2027,11 @@ class Query
|
||||
}
|
||||
// 生成删除SQL语句
|
||||
$sql = $this->builder()->delete($options);
|
||||
|
||||
// 获取参数绑定
|
||||
$bind = $this->getBind();
|
||||
if ($options['fetch_sql']) {
|
||||
// 获取实际执行的SQL语句
|
||||
return $this->connection->getRealSql($sql, $this->bind);
|
||||
return $this->connection->getRealSql($sql, $bind);
|
||||
}
|
||||
|
||||
// 检测缓存
|
||||
@@ -2027,7 +2040,7 @@ class Query
|
||||
Cache::rm($key);
|
||||
}
|
||||
// 执行操作
|
||||
return $this->execute($sql, $this->getBind());
|
||||
return $this->execute($sql, $bind);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user