Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在Codeigniter中使用gDoctirne ORM时出现致命错误_Php_Codeigniter_Doctrine - Fatal编程技术网

Php 在Codeigniter中使用gDoctirne ORM时出现致命错误

Php 在Codeigniter中使用gDoctirne ORM时出现致命错误,php,codeigniter,doctrine,Php,Codeigniter,Doctrine,在Codeigniter中使用ORM时,我收到以下错误消息 ( ! ) Fatal error: Call to a member function getAttribute() on a non-object in C:\xampp\htdocs\giftshoes\system\database\doctrine\Doctrine\Record.php on line 1424 Call Stack # Time Memory Function Location 1 0

在Codeigniter中使用ORM时,我收到以下错误消息

( ! ) Fatal error: Call to a member function getAttribute() on a non-object in C:\xampp\htdocs\giftshoes\system\database\doctrine\Doctrine\Record.php on line 1424
Call Stack
#   Time    Memory  Function    Location
1   0.0011  327560  {main}( )   ..\index.php:0
2   0.0363  3210720 require_once( 'C:\xampp\htdocs\giftshoes\system\codeigniter\CodeIgniter.php' )  ..\index.php:116
3   0.0492  3922368 Welcome->Welcome( ) ..\CodeIgniter.php:201
4   0.0817  6234096 CI_Loader->model( ) ..\welcome.php:14
5   0.0824  6248376 Shoes->__construct( )   ..\Loader.php:184
6   0.0824  6248424 Doctrine_Core::getTable( )  ..\Shoes.php:5
7   0.0824  6248424 Doctrine_Connection->getTable( )    ..\Core.php:1080
8   0.0824  6254304 Doctrine_Table->__construct( )  ..\Connection.php:1123
9   0.0841  6396128 Doctrine_Table->initDefinition( )   ..\Table.php:249
10  0.0841  6397472 Shoes->__construct( )   ..\Table.php:301
11  0.0841  6397680 Doctrine_Access->__set( )   ..\Access.php:0
12  0.0841  6397680 Doctrine_Record->set( ) ..\Access.php:60
------------------条令表定义-------------

class ShoesTable extends Doctrine_Table
{
    function getAllShoes($from = 0, $total = 15)
    {
        $q = Doctrine_Query::create()
        ->from('Shoes s')
        ->limit($total)
        ->offset($from);

        return $q->execute(array(), Doctrine::HYDRATE_ARRAY);
    }

}
------------------------条令表代码-------------------

class ShoesTable extends Doctrine_Table
{
    function getAllShoes($from = 0, $total = 15)
    {
        $q = Doctrine_Query::create()
        ->from('Shoes s')
        ->limit($total)
        ->offset($from);

        return $q->execute(array(), Doctrine::HYDRATE_ARRAY);
    }

}
-----------------模型代码-----------------

class ShoesTable extends Doctrine_Table
{
    function getAllShoes($from = 0, $total = 15)
    {
        $q = Doctrine_Query::create()
        ->from('Shoes s')
        ->limit($total)
        ->offset($from);

        return $q->execute(array(), Doctrine::HYDRATE_ARRAY);
    }

}
我想:

  • 鞋扩展了跑鞋
    ——我们可以看到这一点
  • BaseShoes\u记录
Doctrine\u Record
有一个
\u construct()
方法,它做了很多事情

如果在一个类中重新定义
\uuu construct()
方法,它将重写在其父类中定义的
\uu construct()
方法


在这里:

  • 您的
    Shoes::\uu construct()
    方法
  • 覆盖
    BaseShoes::\uu construct()
  • 它本身不存在,因此与
    原则\u记录::\u构造()
  • 似乎做了一些与教义相关的重要事情;-)

未测试,但在自己的构造函数中调用父构造函数可能会有所帮助:

class Shoes extends BaseShoes
{
    function  __construct() {
        parent::__construct();
        $this->table = Doctrine::getTable('shoes');
    }
    public function getAllShoes()
    {
        $this->table->getAllShoes();
    }
}

并引用PHP手册中的页面作为参考:

注意:如果子类 定义一个构造函数
为了 运行父构造函数,调用
parent::\uu construct()
在 子构造函数是必需的


不过,作为旁注,我不确定在模型类中定义自己的构造函数是否是一个好主意——事实上,据我记忆所及,我从未见过这样做

这里有一个,似乎表明我是对的(引用,强调我的):

[…]有人问起这个问题 第2条中实体的构造 以及是否可以使用。
我认为这是值得的 从第一条原则开始写 这是不可能的。构造器 他是从你那里被偷来用的吗 内部由条令决定


这是教条1.2手册中的相关章节:

条令不允许你推翻
条令\u记录::\u构造()
方法,但提供了一种替代方法
[……]

我想:

  • 鞋扩展了跑鞋
    ——我们可以看到这一点
  • BaseShoes\u记录
Doctrine\u Record
有一个
\u construct()
方法,它做了很多事情

如果在一个类中重新定义
\uuu construct()
方法,它将重写在其父类中定义的
\uu construct()
方法


在这里:

  • 您的
    Shoes::\uu construct()
    方法
  • 覆盖
    BaseShoes::\uu construct()
  • 它本身不存在,因此与
    原则\u记录::\u构造()
  • 似乎做了一些与教义相关的重要事情;-)

未测试,但在自己的构造函数中调用父构造函数可能会有所帮助:

class Shoes extends BaseShoes
{
    function  __construct() {
        parent::__construct();
        $this->table = Doctrine::getTable('shoes');
    }
    public function getAllShoes()
    {
        $this->table->getAllShoes();
    }
}

并引用PHP手册中的页面作为参考:

注意:如果子类 定义一个构造函数
为了 运行父构造函数,调用
parent::\uu construct()
在 子构造函数是必需的


不过,作为旁注,我不确定在模型类中定义自己的构造函数是否是一个好主意——事实上,据我记忆所及,我从未见过这样做

这里有一个,似乎表明我是对的(引用,强调我的):

[…]有人问起这个问题 第2条中实体的构造 以及是否可以使用。
我认为这是值得的 从第一条原则开始写 这是不可能的。构造器 他是从你那里被偷来用的吗 内部由条令决定


这是教条1.2手册中的相关章节:

条令不允许你推翻
条令\u记录::\u构造()
方法,但提供了一种替代方法
[……]


倾向于哪一行是1424行会有帮助。代码现在格式化了。。。1424是Doctrine\Record.phpYes的行号,但确切的行号是什么?将代码块立即发布到它前面。如果($this->u table->getAttribute(Doctrine\u Core::ATTR\u AUTO\u ACCESSOR\u OVERRIDE);$this->hasMutator($fieldName)){$componentName=$this->u table->getComponentName();$mutator=$this->hasMutator($fieldName)?$this->getMutator,第1424行($fieldName):'set'.Doctrine_definctor::classify($fieldName);如果($this->hasMutator($fieldName)| | method_存在($this,$mutator)){$this->hasMutator($fieldName,$mutator);返回$this->$mutator($value,$load);}倾向于哪一行是第1424行会有帮助。代码现在已经格式化了…1424是条令\记录.phpYes的行号,但确切的行号是什么?立即将代码块放到它前面。如果($this->u table->getAttribute(条令\核心::ATTR\ u AUTO\ u ACCESSOR \ u OVERRIDE);$this->hasMutator,则第1424行到1434行($fieldName)){$componentName=$this->_table->getComponentName();$mutator=$this->hasMutator($fieldName)?$this->getMutator($fieldName):'set'。原则_屈折因子::分类($fieldName);如果($this->hasMutator($fieldName)|方法_存在($this,$mutator)){$this->hasMutator($fieldName,$mutator);返回$this->$mutator($value,$load);}