改进Model类的db方法 并增加query属性

This commit is contained in:
thinkphp
2016-05-18 22:33:59 +08:00
parent 67500bc3c9
commit b4d90ade7a
3 changed files with 75 additions and 56 deletions

View File

@@ -593,7 +593,7 @@ class Relation
{
if ($this->model) {
$model = new $this->model;
$db = $model::db();
$db = $model->db();
if (self::HAS_MANY == $this->type && isset($this->parent->{$this->localKey})) {
// 关联查询带入关联条件
$db->where($this->foreignKey, $this->parent->{$this->localKey});