We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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

http://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.