m\modules\v1\controllers\AddressController::actionAll PHP Method

actionAll() public method

public actionAll ( $schoolId = null )
    public function actionAll($schoolId = null)
    {
        $sql = 'SELECT t0.id, t0.consignee, t0.cellphone, t0.gender, t0.school_id, t0.building_id, t0.room, t0.is_default, t1.name AS school_name, t2.name AS building_name FROM {{%address}} AS t0 LEFT JOIN {{%school}} AS t1 ON t0.school_id = t1.id LEFT JOIN {{%building}} AS t2 ON t0.building_id = t2.id WHERE t0.user_id=:uid ORDER BY t1.id, t0.is_default DESC';
        $params = [':uid' => Yii::$app->user->id];
        if ($schoolId !== null) {
            $sql .= ' AND t1.id=:sid';
            $params[':sid'] = $schoolId;
        }
        $list = Yii::$app->db->createCommand($sql, $params)->queryAll(\PDO::FETCH_ASSOC);
        return $list;
    }