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

Adding static method to model

I guess I'm making some newbie mistake here but I can't find whats wrong. I have a model to which I wanted to add static method...

<?php
use Phalcon\Mvc\Model,
Phalcon\Mvc\Model\Message,
Phalcon\Mvc\Model\Validator\InclusionIn,
Phalcon\Mvc\Model\Validator\Uniqueness;

class Venues extends Model {
    public function getSource() {
        return "t_venue";
    }

    public static function geoFind($lat1, $long1, $lat2, $long2) {
        ........
        return $res;
    }
}

Now when I try to call Venues::geoFind method i get message: "Caught exception: The static method "geoFind" doesn't exist on model "Venues". What am I doing wrong?



33.8k

Try to reset the server: aparently, you've it right.



1.3k

Well, restarting server didnt help (i use built-in php server, ubuntu). However i just created same class under new name Venues2 and it worked. Restarted server again, killed all running php processes and its still same. Venues2 works and Venues doesnt. Any ideas?



33.8k

Maybe you didn't get the models folder in the autoloader (don't think so)

BTW, no more ideas.



1.3k

Nah, i have models in autoloader.

Are there any cached files which phalcon could create or something like that?



33.8k

I don't think so. I also have models with static methods, and all of them work perfectly.

But Phalcon has the last word.



1.3k
edited Aug '14

Something is really wrong here. I just removed php files with Venues class definition at all. And i still get same error. Phalcon still "thinks" that class Venues is defined. :/

EDIT: full system reboot also did nothing. I still get this wierd error.



33.8k

Maybe is something related to the built-in. But I didn't work with it yet.