Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
667 views
in Technique[技术] by (71.8m points)

php - ATK4 model not found when moving to online

I am developing a website using ATK4, a php framework with jquery.

I have developed this on my laptop using localhost/test1 as the directory and with a local php database.

If i move all the directories online and import the php database to my web host, most of the pages work but on one, i get an error on one of the pages indicating

Fatal error: Class 'model_TaskType' not found in /homepages/4/d184034614/htdocs/paperless/atk4/lib/AbstractObject.php on line 131

The line referred to in AbstractObject.php is part of the add function.

The model is present and exactly the same code is working on localhost. Other pages also have models and appear to be working fine. The table has exactly the same structure on both databases.

The model is not directly referenced in the page that has a problem, it is a refModel to a Model which is referenced. Is there some path issue here that doesnt present itself on localhost ?

The TaskType model looks like this class Model_TaskType extends Model_Table { public $entity_code='vscrum_tasktype'; public $table_alias='ty';

function init(){
    parent::init();

    $this->addField('id')->mandatory(true);
    $this->addField('name')->mandatory(true);
    $this->addField('budget_code')->mandatory(true);
    $this->addField('colour_desc')->refModel('model_Colour');
    $this->addField('project_id');
    $this->addField('team_id');
    $this->addField('company_id');

    $this->addCondition('team_id',$this->api->getTeamID());
  }

}

and the Task Model which is added to the page with the problem looks like this

  class Model_Task extends Model_Table {
  public $entity_code='vscrum_task';
  public $table_alias='tk'; 

function init(){
    parent::init();

//  debug causes error in Ajax in ATK v4.1.1
//  $this->debug(true);
$this->addField('id')->system(true)->visible(false);
$this->addField('story_id')->system(true)->visible(false);
$this->addField('backlog_ref')->system(true)->visible(false);
$this->addField('sprint_id')->system(true)->visible(false);
$this->addField('team_id')->system(true)->visible(false);
$this->addField('status')->defaultValue('I')->visible(false);
$this->addField('task_desc')->mandatory(true)->visible(true);
$this->addField('points')->mandatory(true)->defaultValue(1)->datatype('numeric');
    $this->addField('member_id')->mandatory(true)->refModel('model_Member');

    // join colour
    $this->addRelatedEntity('ty','vscrum_tasktype','tasktype_id','left');

    //tasktype
    $this->addField('tasktype_id')->refModel('model_TaskType')->mandatory(true);

}
}

Maybe i've missed something obvious, any ideas why this would work fine on localhost but break on my webhost ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
 Class 'model_TaskType' not found in 

you should always use exact capitalization.

if you have Model_TaskType, it should be Model_TaskType when added to CRUD.

also this place:

$this->addField('tasktype_id')->refModel('model_TaskType')->mandatory(true);

should be:

$this->addField('tasktype_id')->refModel('Model_TaskType')->mandatory(true);

On widows, file name capitalization does not make a difference, where as in linux it does.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...