A
A
alexflitcher12022-04-12 19:36:48
PHP
alexflitcher1, 2022-04-12 19:36:48

Yii\rest\ActiveController does not work with large tables. Why?

Hello, I ran into a problem, when creating a RESTful API based on Yii2, the yii\rest\ActiveController class refuses to work with large tables, but it works fine with trial tables. Why and how to solve it?
UserController.php

<?php
namespace backend\controllers;

use backend\models\User;
use yii\rest\ActiveController;

class UserController extends ActiveController
{
    public $modelClass = 'backend\models\User';
}

urlManager
'urlManager' => [
            'enablePrettyUrl' => true,
            'enableStrictParsing' => true,
            'showScriptName' => false,
            'rules' => [
                [
                    'class' => 'yii\rest\UrlRule',
                    'controller' => 'user',
                ],
            ],
        ],

user.php
<?php
namespace backend\models;

use yii\db\ActiveRecord;

/**
 * User model
 * 
 * Table: user
 */
class User extends ActiveRecord
{
    public static function tableName()
    {
        return '{{users}}';
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question