修正PDO参数绑定的一处BUG

This commit is contained in:
thinkphp
2016-01-20 19:13:03 +08:00
parent a17080244e
commit 6d8191d63c
6 changed files with 12 additions and 18 deletions

View File

@@ -178,11 +178,6 @@ class View
$replace = $this->config['parse_str'];
$content = str_replace(array_keys($replace), array_values($replace), $content);
}
if (APP_DEBUG && $this->config['parse_var']) {
// debug模式时将后台分配变量输出到浏览器控制台
$parseVar = empty($vars) ? json_encode([]) : json_encode($vars);
$content .= '<script type="text/javascript">var __VAR__ = ' . $parseVar . ';</script>';
}
return $content;
}

View File

@@ -432,8 +432,8 @@ abstract class Driver
$set[] = $this->parseKey($key) . '=' . $val;
} else {
$name = count($this->bind);
$set[] = $this->parseKey($key) . '=:' . $name;
$this->bindParam($name, $val);
$set[] = $this->parseKey($key) . '=:' . $key . '_' . $name;
$this->bindParam($key . '_' . $name, $val);
}
}
}
@@ -458,7 +458,7 @@ abstract class Driver
* @param string $key
* @return string
*/
protected function parseKey(&$key)
protected function parseKey($key)
{
return $key;
}
@@ -539,8 +539,7 @@ abstract class Driver
}
$tables = $array;
} elseif (is_string($tables)) {
$tables = explode(',', $tables);
array_walk($tables, [ & $this, 'parseKey']);
$tables = array_map([$this, 'parseKey'], explode(',', $tables));
}
return implode(',', $tables);
}
@@ -913,8 +912,8 @@ abstract class Driver
$values[] = $val;
} else {
$name = count($this->bind);
$values[] = ':' . $name;
$this->bindParam($name, $val);
$values[] = ':' . $key . '_' . $name;
$this->bindParam($key . '_' . $name, $val);
}
}
}
@@ -983,8 +982,8 @@ abstract class Driver
$fields = explode(',', $fields);
}
array_walk($fields, [$this, 'parseKey']);
$sql = 'INSERT INTO ' . $this->parseTable($table) . ' (' . implode(',', $fields) . ') ';
$fields = array_map([$this, 'parseKey'], $fields);
$sql = 'INSERT INTO ' . $this->parseTable($table) . ' (' . implode(',', $fields) . ') ';
$sql .= $this->buildSelectSql($options);
return $this->execute($sql, !empty($options['fetch_sql']) ? true : false);
}

View File

@@ -90,7 +90,7 @@ class Mysql extends Driver
* @param string $key
* @return string
*/
protected function parseKey(&$key)
protected function parseKey($key)
{
$key = trim($key);
if (strpos($key, '$.') && false === strpos($key, '(')) {

View File

@@ -179,7 +179,7 @@ class Oracle extends Driver
* @param string $key
* @return string
*/
protected function parseKey(&$key)
protected function parseKey($key)
{
$key = trim($key);
if (strpos($key, '$.') && false === strpos($key, '(')) {

View File

@@ -100,7 +100,7 @@ class Pgsql extends Driver
* @param string $key
* @return string
*/
protected function parseKey(&$key)
protected function parseKey($key)
{
$key = trim($key);
if (strpos($key, '$.') && false === strpos($key, '(')) {

View File

@@ -108,7 +108,7 @@ class Sqlsrv extends Driver
* @param string $key
* @return string
*/
protected function parseKey(&$key)
protected function parseKey($key)
{
$key = trim($key);
if (!preg_match('/[,\'\"\*\(\)\[.\s]/', $key)) {