远程一对多的源码是不是有点点小错误?

浏览:274 发布日期:2017/05/19 分类:ThinkPHP5专区 关键字: tp5
protected function baseQuery()
{
    if (empty($this->baseQuery) && $this->parent->getData()) {
        $through      = $this->through;
        $model        = $this->model;
        $alias        = Loader::parseName(basename(str_replace('\\', '/', $model)));
        $throughTable = $through::getTable();

         //$this->model该换成$this->through
        $pk           = (new $this->model)->getPk(); 

        $throughKey   = $this->throughKey;
        $modelTable   = $this->parent->getTable();
        $this->query->field($alias . '.*')->alias($alias)
         
            ->join($throughTable, $throughTable . '.' . $pk . '=' . $alias . '.' . $throughKey)
            ->join($modelTable, $modelTable . '.' . $this->localKey . '=' . $throughTable . '.' . $this->foreignKey)
            ->where($throughTable . '.' . $this->foreignKey, $this->parent->{$this->localKey});
        $this->baseQuery = true;
    }
}
最佳答案
评论( 相关
后面还有条评论,点击查看>>