select
,
distinct
,
calcFoundRows
,
where
,
orWhere
,
having
,
orHaving
,
orderBy
,
groupBy
,
limit
,
offset
,
join
,
leftJoin
,
rightJoin
,
Countable
,
IteratorAggregate
,
JsonSerializable
, ArrayAccess
.
So you could counting, iterate, encode as json or interacting it as array style.
Collection have 2 fallback method to model: save
and delete
and the model property setter.
Lazy Model support Lazy Loading. By default, the column types below considering as Lazy Loading:
Model::TEXT (text)
Model::MEDIUMTEXT (mediumtext)
Model::LONGTEXT (longtext)
Model::BLOB (blob)
Model::MEDIUMBLOB (mediumblob)
Model::LONGBLOB (longblob)
$defaultLazyLoadColumnTypes
or $defaultSelectColumns
in your model definition.
As you see. The column content
of posts table not selected yet. But when the first time you get the content property,
it will select the content
column related to the collection.
The Eager Loading existing to resolve the N + 1
query problem.
For example, in the Defining Models,
the Post
model related to User
model specified by Creator
.
See an example above, we retrieving the creator name of post collection:
Assume the posts table have 100
records.
Normally, you are guessing there are total 101
queries executed.
1
is for the posts list, and 100
queries for each post to retrieving the creator name.
Actually, there are just 2
queries executed:
with('Creator')