Note that there are some explanatory texts on larger screens.

plurals
  1. UShumeniuc
    primarykey
    data
    text
    plurals
    1. COThe situation with posts,comments,users was purely demonstrational. The same for the number of returned results, so not the page structure, loader, etc was the issue. Hoever thank you for the sugestion for not using the ActiveRecord. It seems that AR was designed for mor simple tasks. It is a shame that Yii does not have a 'post objects initialization bulk initialize a relation' feature in their AR.
      singulars
    2. CO@dInGd0nG I have three main reasons: 1. Performance. I have objects with plenty of relations. If I join them using "with" it could lead to big and slow queryes. 2. Legacy code. I have the parent of objects (in example $posts) as a result from a function. It is more convenient to attach the related objects to thhe results, rather than modifing the function (which could lead into breaking other parts of the code ). 3. Flexibility. I'm not forced to think in advance what relations I need, I can easely (and with less database stress) attach the relations to an set of parent objects.
      singulars
    3. COThat procedure is the oposite of what I need. I can't use with and together. In the simple example with posts and comments if I need to show 100 post, and each one have 200 comments then the with+together would create a query that generates an 2000 rows. In real life applications this procedure could lead to very slow querys
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload