The problem with calling models

Error:

Fatal error: Call to undefined method Directory::find() in C:\SERVER_DIR\app\controllers\IndexController.php

IndexController.php

class IndexController extends ControllerBase
{

    public function indexAction()
    {
        $this->view->title = 'Title';

        $this->view->directory = Directory::find();
    }

}

Directory.php

class Directory extends \Phalcon\Mvc\Model
{

    /**
     *
     * @var integer
     */
    public $id;

    /**
     *
     * @var string
     */
    public $slug;

    /**
     *
     * @var string
     */
    public $title;

    /**
     * Independent Column Mapping.
     */
    public function columnMap()
    {
        return array(
            'id' => 'id', 
            'slug' => 'slug', 
            'title' => 'title'
        );
    }

}

Object category is created. What could be the problem?



28.2k

is your models directory registred by phalcon's loader ?

$loader = new \Phalcon\Loader();

$loader->registerDirs(

array(

    $config->application->controllersDir,

    $config->application->modelsDir

)

)->register();

Yes.

loader.php:

<?php

$loader = new \Phalcon\Loader();

/**
 * We're a registering a set of directories taken from the configuration file
 */
$loader->registerDirs(
    array(
        $config->application->controllersDir,
        $config->application->modelsDir
    )
)->register();


28.2k

What happens if you remove column mapping (in your case, it does not look really usefull) ?

Also test if you can create a new Directory Object.

Nothing happened. Model I generated through DevTools.

Very strange. Renamed "sections" and earned. Perhaps the word "directory" incorrectly perceived framework.



28.2k

ok, that's strange indeed. Maybe someone from the team can tell us more about that.

Glad that you've found a solution.