调用成员函数getAllHash

时间:2011-09-19 16:14:12

标签: php atk4

我正在尝试运行atk4网站上提供的示例代码。下载代码,创建模型和生成页面。但是,当我尝试使用http://localhost/demo/atk4-example/?page=generate生成SQL时,我在apache错误日志中出现以下错误:

[Mon Sep 19 21:35:31 2011] [error] [client 127.0.0.1] PHP Fatal error:  Call to a member function getAllHash() on a non-object in /var/www/html/demo/atk4-example/atk4-addons/mvc/Page/SchemaGenerator.php on line 69, referer: http://localhost/demo/atk4-example/?page=generate

以下是模特:

Category.php:

class Model_Category extends Model_Table {
    public $entity_code = 'category_table';
    public $table_alias = 'ct';
    function init(){
        parent::init();

        $this->addField('name');
    }
}

Job.php:

class Model_Job extends Model_Table {
    public $entity_code = 'job_table';
    public $table_alias = 'jt';
    function init(){
        parent::init();
        $this->addField('category_id')->refModel('Model_Category');
        $this->addField('type');
        $this->addField('company');
        $this->addField('logo');
        $this->addField('url');
        $this->addField('position');
        $this->addField('location');
        $this->addField('description')->type('text');
        $this->addField('how_to_apply')->type('text');
        $this->addField('is_public')->type('boolean');
        $this->addField('is_activated')->type('boolean');
        $this->addField('email');
        $this->addField('token');
        $this->addField('created_dts')->type('timestamp')->system(true);
        $this->addField('updated_dts')->type('timestamp')->system(true);
        $this->addField('expires_at')->type('date')->system(true);
    }
}

页/ generate.php:

class page_generate extends Page_SchemaGenerator {}

我错过了一些路径设置吗?

1 个答案:

答案 0 :(得分:2)

Call to a member function getAllHash() on a non-object in
/var/www/html/demo/atk4-example/atk4-addons/mvc/Page/SchemaGenerator.php
on line 69

,这一行是

$res = $this->api->db->getAllHash("desc $table");

意味着$this->api->db不是对象 看看atk4-example / page / dbtest.php。它会调用$this->api->dbConnect();,它可能会设置api> db属性。