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

Identifying if the given object is a collection model or base model

Is there any way to dynamically know if the given object is collection based or base ? In addition any way to import all of the model namespaces to a component dynamically with Phalcon ? (except traditional php auto loading)

What you mean ? if you do ::find - you have collection, if you do findFirst you have base model, if you select any columns - you have simple object.

You can check the variable type using instanceof and compare it against specific model classes.

if ($result instanceof \Phalcon\Mvc\Model) {
  // This is a single Model instance
else if ($result instanceof \Phalcon\Mvc\Model\Resultset) {
  // This is a Resultset instance
else if ($result instanceof \Phalcon\Mvc\Model\Criteria) {
  // This is a Criteria instance

Is this what you were after?

You can do that with 'instanceof' but i was looking for a Phalcon way if there's one something like Model::getType()

I need to know if the passed model object is a collection or base instance before performing queries as ::find etc

I manually implemented that by adding a getType method in each model class to return get_parent_class() and i do $modelname::getType()