mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +08:00
Traits/Think/Model/Query 中的query和execute方法采用参数绑定机制
parseSql方法独立使用 保留原来的预处理机制。
This commit is contained in:
@@ -46,32 +46,22 @@ trait Query {
|
|||||||
* SQL查询
|
* SQL查询
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $sql SQL指令
|
* @param string $sql SQL指令
|
||||||
* @param mixed $parse 是否需要解析SQL
|
* @param array $bind 参数绑定
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function query($sql,$parse=false) {
|
public function query($sql,$bind=[]) {
|
||||||
if(!is_bool($parse) && !is_array($parse)) {
|
return $this->db->query($sql,$bind);
|
||||||
$parse = func_get_args();
|
|
||||||
array_shift($parse);
|
|
||||||
}
|
|
||||||
$sql = $this->parseSql($sql,$parse);
|
|
||||||
return $this->db->query($sql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行SQL语句
|
* 执行SQL语句
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $sql SQL指令
|
* @param string $sql SQL指令
|
||||||
* @param mixed $parse 是否需要解析SQL
|
* @param array $bind 参数绑定
|
||||||
* @return false | integer
|
* @return false | integer
|
||||||
*/
|
*/
|
||||||
public function execute($sql,$parse=false) {
|
public function execute($sql,$bind=[]) {
|
||||||
if(!is_bool($parse) && !is_array($parse)) {
|
return $this->db->execute($sql,$bind);
|
||||||
$parse = func_get_args();
|
|
||||||
array_shift($parse);
|
|
||||||
}
|
|
||||||
$sql = $this->parseSql($sql,$parse);
|
|
||||||
return $this->db->execute($sql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,7 +71,7 @@ trait Query {
|
|||||||
* @param boolean $parse 是否需要解析SQL
|
* @param boolean $parse 是否需要解析SQL
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseSql($sql,$parse) {
|
public function parseSql($sql,$parse) {
|
||||||
// 分析表达式
|
// 分析表达式
|
||||||
if(true === $parse) {
|
if(true === $parse) {
|
||||||
$options = $this->_parseOptions();
|
$options = $this->_parseOptions();
|
||||||
|
|||||||
Reference in New Issue
Block a user