转到在线时找不到 ATK4 模型

发布于 2024-12-05 15:03:34 字数 2351 浏览 0 评论 0原文

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

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

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

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

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

该模型已存在,并且完全相同的代码正在本地主机上运行。其他页面也有模型并且看起来工作正常。该表在两个数据库上具有完全相同的结构。

该模型并不是在有问题的页面中直接引用的,它是对被引用模型的 refModel。这里是否存在一些在本地主机上没有出现的路径问题?

TaskType 模型如下所示 类 Model_TaskType 扩展 Model_Table { 公共$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);

}
}

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

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

起风了 2024-12-12 15:03:34
 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 中却有区别。

 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.

留蓝 2024-12-12 15:03:34

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

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

PathFinder 将所有下划线 _ 实例更改为 / 并相应地遍历位置。

因此,像这样的声明:

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

in my experience with ATK4 (v4.1.3) this error is more likely a case-sensitivity and folder search declaration problem.

as the ATK4 PathFinder is the one responsible for loading all the classes, when you add() an object, like, Model_UserAccess it looks for different locations particularly: Model/UserAccess.php it then include() the file and then instantiates the class Model_UserAccess inside it, something like return new Model_UserAccess().

PathFinder changes all instances of underscores _ to / and traverse the locations accordingly.

therefore, a declaration something like this:

class Model_UserAccess extends Model_Table

and adding it:

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

searches and loads two files (not in particular order), 1st from: /Model/Table.php and 2nd from: /Model/UserAccess.php

once you are comfortable with this folder separation concept, developing in ATK4 will be much much easier.

i myself have a /lib/Model/ and /lib/Form/ and even a /lib/Form/Field/ since i am also redefining up to the field level. The latter would look something like:

class Form_Field_GraduatedSlider extends Form_Field

千寻… 2024-12-12 15:03:34

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

我有一个名为 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​​ 的模型,它扩展了任务

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,所以我假设它会获取添加到任务中的所有字段

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

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

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

OK, seems a bit strange but this is what i found.

I have a model called Task which extends 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);
 }

I have a model called ScrumwallTask which extends 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 calls parent::init so i assumed it would get all the fields added to Task

I got rid of the error by duplicating the addField for tasktype_id into ScrumwallTask even though it is already defined in the parent Task.

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

Is that expeced behaviour for inheritance of models ?
What is really confusing is that it worked fine on localhost (Windows 7) !

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文