From 438330a4b2ffa4f1892784212d3963c2b65b11fb Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 28 Jun 2016 19:07:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BBdelete=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=8F=82=E6=95=B0=E9=BB=98=E8=AE=A4=E5=80=BC=E4=B8=BA?= =?UTF-8?q?null=20=E5=BD=93=E5=8F=82=E6=95=B0=E4=B8=BAtrue=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=20=E8=A1=A8=E7=A4=BA=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index edeefb72..b6719410 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -1871,7 +1871,7 @@ class Query * @throws Exception * @throws PDOException */ - public function selectOrFail($data = []) + public function selectOrFail($data = null) { return $this->failException(true)->select($data); } @@ -1885,7 +1885,7 @@ class Query * @throws Exception * @throws PDOException */ - public function findOrFail($data = []) + public function findOrFail($data = null) { return $this->failException(true)->find($data); } @@ -1948,22 +1948,22 @@ class Query /** * 删除记录 * @access public - * @param array $data 表达式 + * @param mixed $data 表达式 true 表示强制删除 * @return int * @throws Exception * @throws PDOException */ - public function delete($data = []) + public function delete($data = null) { // 分析查询表达式 $options = $this->parseExpress(); - if (!empty($data)) { + if (!is_null($data) && true !== $data) { // AR模式分析主键条件 $this->parsePkWhere($data, $options); } - if (empty($options['where'])) { + if (true !== $data && empty($options['where'])) { // 如果条件为空 不进行删除操作 除非设置 1=1 throw new Exception('delete without condition'); }