Application without active record

Hi all. I want to ask guru of php. What do you think, can developer use yii without active record?

In big projects active record is needs a lot of resources, and better to use sql for getting data.

How do you build your application without active record or do you use mix of active record and sql?

Do you create some extention (component, repository,service) ? What advice can you give?

Thank you for answers :)

The main thing is to understand the kind of big project.

If your site has to handle many requests per second, probably the best choice is not even php, nor yii.

But if it is a web application where the requests per second are not excessive, all the advantages and reusability that Active Records are incomparable to direct sql.

If I want to get 1000 records, 1000 objects will be crated by active record. It is costly, am I right?

Sure.

But what is the purpose to have 1000 records?

This problem is solved with pagination, getting only fields that you need to display.

In documentation we have this part

Using asArray

A good way to save memory and processing time on read-only pages is to use ActiveRecord’s asArray method.




class PostController extends Controller

{

    public function actionIndex()

    {

        $posts = Post::find()->orderBy('id DESC')->limit(100)->asArray()->all();

        return $this->render('index', ['posts' => $posts]);

    }

}



so I can also do this:




class Record extends ActiveRecord {

    .....

    

    public static function getAllRecords() {

        return Yii::$app->db->createCommand('SELECT * FROM records')->queryAll();

    }

    

    ....

}


and use it as Record::getAllRecords



Record::getAllRecords will return me array.

Is it normal way?