From ecf2bf50e5a306e192f6217ae3292d3d56a77039 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 10 Apr 2016 12:06:18 +0800 Subject: [PATCH] =?UTF-8?q?Model=E7=B1=BB=E7=9A=84create=E5=92=8Cupdate?= =?UTF-8?q?=E9=9D=99=E6=80=81=E6=96=B9=E6=B3=95=20=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E6=A8=A1=E5=9E=8B=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index c5b97bc4..3aad0536 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -578,12 +578,13 @@ abstract class Model implements \JsonSerializable, \ArrayAccess * 写入数据 * @access public * @param array $data 数据数组 - * @return integer + * @return Model */ public static function create($data = []) { $model = new static(); - return $model->isUpdate(false)->save($data); + $model->isUpdate(false)->save($data); + return $model; } /** @@ -596,7 +597,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess public static function update($data = [], $where = []) { $model = new static(); - return $model->isUpdate(true)->where($where)->save($data); + $model->isUpdate(true)->where($where)->save($data); + return $model; } /** @@ -628,14 +630,15 @@ abstract class Model implements \JsonSerializable, \ArrayAccess } /** - * 查找多条记录 + * 查找所有记录 * @access public * @param mixed $data 主键列表 - * @return array|string + * @param string $with 关联预查询 + * @return mixed */ - public static function all($data = []) + public static function all($data = [], $with = '') { - return self::db()->select($data); + return self::db()->with($with)->select($data); } /**