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.

Exception: Call to undefined method Phalcon\Db\Adapter\Pdo\Mysql::selectcollection()

Hi There,

I got a question, I am getting this exception: Call to undefined method Phalcon\Db\Adapter\Pdo\Mysql::selectcollection().

I do not understand what I am missing here and where I need to put it. It occurs whenever I try to call this in the model:

public function initialize()

and it is defined on index as:

$di->set('connection', function(){
    return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
        "host" => "",
        "username" => "username",
        "password" => "password",
        "dbname" => "database",
        "port" => 0000,
        'charset' => 'utf8',

I tried to look on the web but can't get anything to make it work. Please advice.


edited May '16

selectcollection is just method for mongo, not for mysql, such an method just don't exist for mysql beacause you don't have collections in it.


I was planning to use ORM. The model it is being referred to is a subclass of Models. Your assumption is correct, thanks. What I am puzzled now is that it is being seen as a collection instead of being a model.

This is the model:

class SomeModel extends Models
  public function initialize()

And when I am accessing it in the controller:

$result = SomeModel::find("some_field=1");

Did I miss something here?


Ah, found it.

Instead of Model, I used Models. Apparently, Models was created that extends Collection that's why I was not able to notice about the error on using Model instead.

Thanks for clearing things up earlier. Cheers.