1

我正在使用 ATK4 开发一个网站,这是一个带有 jquery 的 php 框架

我在笔记本电脑上使用 localhost/test1 作为目录并使用本地 php 数据库开发了它。

如果我将所有目录在线移动并将 php 数据库导入到我的网络主机,大多数页面都可以工作,但在一个页面上,我在其中一个页面上收到错误指示

致命错误:在第 131 行的 /homepages/4/d184034614/htdocs/paperless/atk4/lib/AbstractObject.php 中找不到类“model_TaskType”

AbstractObject.php 中引用的行是 add 函数的一部分。

该模型存在,并且完全相同的代码在 localhost 上运行。其他页面也有模型并且似乎工作正常。该表在两个数据库上具有完全相同的结构。

该模型没有在有问题的页面中直接引用,它是一个引用模型的 refModel。这里是否有一些路径问题不会出现在 localhost 上?

TaskType 模型看起来像这个类 Model_TaskType extends Model_Table { public $entity_code='vscrum_tasktype'; 公共 $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());
  }

}

并且添加到有问题的页面的任务模型看起来像这样

  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);

}
}

也许我错过了一些明显的东西,任何想法为什么这在 localhost 上可以正常工作但在我的网络主机上中断?

4

3 回答 3

1

根据我对 ATK4 (v4.1.3) 的经验,这个错误更可能是区分大小写和文件夹搜索声明问题。

由于 ATK4 PathFinder 负责加载所有类,因此当您add()使用对象时,Model_UserAccess它会特别查找不同的位置:Model/UserAccess.php然后include()是文件,然后实例化其中的类Model_UserAccess,例如return new Model_UserAccess().

路径查找器将所有下划线实例更改_/并相应地遍历位置。

因此,这样的声明:

class Model_UserAccess extends Model_Table

并添加它:

$m = $this->add('Model_UserAccess');

搜索并加载两个文件(不按特定顺序),第一个来自:/Model/Table.php和第二个来自:/Model/UserAccess.php

一旦您对这种文件夹分离概念感到满意,在 ATK4 中进行开发就会容易得多。

我自己有一个/lib/Model//lib/Form/甚至一个,/lib/Form/Field/因为我也在重新定义到现场级别。后者看起来像:

class Form_Field_GraduatedSlider extends Form_Field

于 2012-01-07T06:04:11.863 回答
1
 Class 'model_TaskType' not found in 

您应该始终使用精确的大小写。

如果你有 Model_TaskType,添加到 CRUD 时应该是 Model_TaskType。

还有这个地方:

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

应该:

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

在寡妇上,文件名的大小写没有区别,而在 linux 中则有区别。

于 2011-09-19T10:19:11.037 回答
0

好的,看起来有点奇怪,但这就是我发现的。

我有一个名为 Task 的模型,它扩展了 Table。

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

function init(){
  parent::init();
  $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('status')->defaultValue('I')->visible(false);
  $this->addField('task_desc')->mandatory(true)->visible(true);

      $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);
 }

我有一个名为 ScrumwallTask​​ 的模型,它扩展了 Task

class Model_ScrumwallTask extends Model_Task {

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

  $this->addField('status')->defaultValue('I')->system(true);
      $this->addField('colour_desc')->datatype('text')->calculated(true);
      $this->addField('status')->visible(true);

    }

function calculate_colour_desc(){
        return $this->api->db->dsql()
            ->table('vscrum_colour')
            ->where('id=ty.colour_id')
            ->field('colour_desc')
            ->select();
    }
}

ScrumwallTask​​ 调用 parent::init 所以我认为它会将所有字段添加到 Task

我通过将 tasktype_id 的 addField 复制到 ScrumwallTask​​ 中来消除错误,即使它已经在父任务中定义。

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

这是模型继承的预期行为吗?真正令人困惑的是它在 localhost (Windows 7) 上运行良好!

于 2011-09-19T05:36:17.500 回答