2019-03-09 16:50:53 1373次浏览 1条回答 0 悬赏 10 金钱
public function all($db = null)
{
    if ($this->emulateExecution) {
        return [];
    }

    // TODO add support for orderBy
    $data = $this->executeScript($db, 'All');
    if (empty($data)) {
        return [];
    }
    $rows = [];
    foreach ($data as $dataRow) {
        $row = [];
        $c = count($dataRow);
        for ($i = 0; $i < $c;) {
            $row[$dataRow[$i++]] = $dataRow[$i++];
        }

        $rows[] = $row;
    }
    if (!empty($rows)) {
        $models = $this->createModels($rows);
        if (!empty($this->with)) {
            $this->findWith($this->with, $models);
        }
        if (!$this->asArray) {
            foreach ($models as $model) {
                $model->afterFind();
            }
        }

        return $models;
    } else {
        return [];
    }
}

最佳答案

  • 刘师傅 发布于 2019-03-11 09:40 举报

    源码都贴出来了,另外方法上面还有注释呢,你咋不贴出来呢?
    说这些有点大了。其实是你阅读代码能力不行。再说了,网站还是有文档的。这种问题,我先给你一棒子。
    文档在【查询构造器】,多看看执行下就明白了。
    https://www.yiichina.com/doc/guide/2.0/db-query-builder
    好好看,好好学,记得写笔记!

    没有找到数据。
您需要登录后才可以回答。登录 | 立即注册
PHP学院的中学生
副总裁

PHP学院的中学生

注册时间:2018-10-23
最后登录:2024-04-07
在线时长:168小时1分
  • 粉丝29
  • 金钱4730
  • 威望30
  • 积分6710

热门问题