修正Driver类的getBindSql方法 异常信息显示当前sql语句

This commit is contained in:
thinkphp
2016-01-27 21:56:01 +08:00
parent faaf99c036
commit d8e1d3eec7

View File

@@ -192,7 +192,7 @@ abstract class Driver
$this->debug(false); $this->debug(false);
return $this->getResult(); return $this->getResult();
} catch (\PDOException $e) { } catch (\PDOException $e) {
throw new Exception($e->getMessage()); throw new Exception($this->getError());
} }
} }
@@ -241,7 +241,7 @@ abstract class Driver
} }
return $this->numRows; return $this->numRows;
} catch (\PDOException $e) { } catch (\PDOException $e) {
throw new Exception($e->getMessage()); throw new Exception($this->getError());
} }
} }
@@ -256,11 +256,11 @@ abstract class Driver
{ {
if ($bind) { if ($bind) {
foreach ($bind as $key => $val) { foreach ($bind as $key => $val) {
$val = is_array($val) ? $val[0] : $val; $val = $this->parseValue(is_array($val) ? $val[0] : $val);
// 判断占位符 // 判断占位符
$sql = is_numeric($key) ? $sql = is_numeric($key) ?
substr_replace($sql, $val, strpos($sql, '?'), 1) : substr_replace($sql, $val, strpos($sql, '?'), 1) :
str_replace(':' . $key, $this->parseValue($val), $sql); str_replace(':' . $key, $val, $sql);
} }
} }
return $sql; return $sql;