We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Parameter "columns" in \Phalcon\Mvc\Model::findFirst()

https://docs.quyun.net/man/phalcon/reference/models.html#finding-records

In this section, you can find a parameter "columns" as a query option: Description: Return specific columns instead of the full columns in the model. When using this option an incomplete object is returned Example: “columns” => “id, name”

I just try and find it return a Phalcon\Mvc\Model\Row object if I pass columns to findFirst(). And a Phalcon\Mvc\Model object will return if I don't pass this param.

But what does it mean of "When using this option an incomplete object is returned"?



21.8k
Accepted
answer

For instance if your object has the following properies :

id name age email

but you do "columns"=>"id,email"

then you will get an object where only id and email will be hydrated. That's why we say that it is incomplete.