mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
Think/Db/Driver类改进自动参数绑定的处理
This commit is contained in:
@@ -327,9 +327,13 @@ abstract class Driver {
|
|||||||
foreach ($data as $key=>$val){
|
foreach ($data as $key=>$val){
|
||||||
$value = $this->parseValue($val);
|
$value = $this->parseValue($val);
|
||||||
if(is_scalar($value)) {// 过滤非标量数据
|
if(is_scalar($value)) {// 过滤非标量数据
|
||||||
$name = md5($key);
|
if(0===strpos($value,':')){
|
||||||
$set[] = $this->parseKey($key).'=:T'.$name;
|
$set[] = $this->parseKey($key).'='.$value;
|
||||||
$this->bindParam($name,$value);
|
}else{
|
||||||
|
$name = md5($key);
|
||||||
|
$set[] = $this->parseKey($key).'=:T'.$name;
|
||||||
|
$this->bindParam($name,$value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ' SET '.implode(',',$set);
|
return ' SET '.implode(',',$set);
|
||||||
@@ -740,9 +744,13 @@ abstract class Driver {
|
|||||||
$value = $this->parseValue($val);
|
$value = $this->parseValue($val);
|
||||||
if(is_scalar($value)) { // 过滤非标量数据
|
if(is_scalar($value)) { // 过滤非标量数据
|
||||||
$fields[] = $this->parseKey($key);
|
$fields[] = $this->parseKey($key);
|
||||||
$name = md5($key);
|
if(0===strpos($value,':')){
|
||||||
$values[] = ':'.$name;
|
$values[] = $value;
|
||||||
$this->bindParam($name,$value);
|
}else{
|
||||||
|
$name = md5($key);
|
||||||
|
$values[] = ':T'.$name;
|
||||||
|
$this->bindParam($name,$value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql = ($replace?'REPLACE':'INSERT').' INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES ('.implode(',', $values).')';
|
$sql = ($replace?'REPLACE':'INSERT').' INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES ('.implode(',', $values).')';
|
||||||
|
|||||||
Reference in New Issue
Block a user