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

error on findFirst method

Hi, i was trying some phalcon's functionalities and on this method:

$profile = OldProfiles::findFirst("ciao");

the framework give me this exception:

*PhalconException: Column 'ciao' doesn't belong to any of the selected models (1), when preparing: SELECT [OldProfiles]. FROM [OldProfiles] WHERE ciao LIMIT 1**

I think it's strange beacuse the primary key of my db is an ID but i passed to the findfirst method a string, so i understand the exception but i don't know why phalcon don't say me that it want an ID but warn me about the not existence of "ciao" column.

Any idea? Thank you

You're passing a condition there, if you want to query by a specific field you have to do:

$profile = OldProfiles::findFirstById("ciao");

ty again :)