1
我試圖運行atk4網站上提供的示例代碼。下載了代碼,創建了模型和生成頁面。然而,當我試圖使用生成的http://localhost/demo/atk4-example/?page=generate SQL,我在Apache的錯誤日誌中有以下錯誤:調用成員函數getAllHash
[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');
}
}
工作.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);
}
}
page/generate.php:
class page_generate extends Page_SchemaGenerator {}
我是否缺少一些路徑設置?
是的,確保在lib/Frontend.php的init()函數中有$ this-> dbConnect()。 – romaninsh
感謝您的超快速幫助。有效 :) – libregeek