framework icon indicating copy to clipboard operation
framework copied to clipboard

ThinkPHP5.1.38 BelongsTo文件$softDelete 变量未引用

Open maymo opened this issue 6 years ago • 0 comments

` /** * 根据关联条件查询当前模型 * @access public * @param string $operator 比较操作符 * @param integer $count 个数 * @param string $id 关联表的统计字段 * @param string $joinType JOIN类型 * @return Query / public function has($operator = '>=', $count = 1, $id = '', $joinType = 'INNER') { $table = $this->query->getTable(); $model = basename(str_replace('\', '/', get_class($this->parent))); $relation = basename(str_replace('\', '/', $this->model)); $localKey = $this->localKey; $foreignKey = $this->foreignKey; $softDelete = $this->query->getOptions('soft_delete');

    return $this->parent->db()
        ->alias($model)
        **->whereExists(function ($query) use ($table, $model, $relation, $localKey, $foreignKey) {**
            $query->table([$table => $relation])
                ->field($relation . '.' . $localKey)
                ->whereExp($model . '.' . $foreignKey, '=' . $relation . '.' . $localKey)
                ->when($softDelete, function ($query) use ($softDelete, $relation) {
                    $query->where($relation . strstr($softDelete[0], '.'), '=' == $softDelete[1][0] ? $softDelete[1][1] : null);
                });
        });
}`

maymo avatar Oct 09 '19 06:10 maymo