2010-04-13 6 views
0

Codeigniter에서 Doctrine ORM을 사용할 때 다음 오류 메시지가 나타납니다.Codeigniter의 ORD를 사용하는 중 오류가 발생했습니다.

(!) 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.720 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 

------------------ 교리 테이블 정의 -------------

abstract class BaseShoes extends Doctrine_Record 
{ 
    public function setTableDefinition() 
    { 
     $this->setTableName('shoes'); 
     $this->hasColumn('sku', 'integer', 11, array('primary' => true, 'autoincrement' => false)); 
     $this->hasColumn('name', 'string', 255); 
     $this->hasColumn('keywords', 'string', 255); 
     $this->hasColumn('description', 'string'); 
     $this->hasColumn('manufacturer', 'string', 20); 
     $this->hasColumn('sale_price', 'double'); 
     $this->hasColumn('price', 'double'); 
     $this->hasColumn('url', 'string'); 
     $this->hasColumn('image', 'string'); 
     $this->hasColumn('category', 'string', 50); 
    } 

    public function setUp() { 

    } 
} 

- ---------------------- Doctrine Table Code -------------------

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 Shoes extends BaseShoes 
{ 
    function __construct() { 
     $this->table = Doctrine::getTable('shoes'); 
    } 
    public function getAllShoes() 
    { 
     $this->table->getAllShoes(); 
    } 
} 
+0

라인 1424 라인이 경사면이 도움이 될 것입니다. – Danten

+0

코드가 지금 포맷되었습니다 ... 1424는 Doctrine \ Record.php의 라인 번호입니다 –

+0

예, 그 정확한 라인 번호는 무엇입니까? 코드 덩어리를 즉시 게시하여 그 코드로 연결합니다. – Danten

답변

3
물론, 우리는
  • BaseShoes extends Doctrine_Record
  • Doctrine_Record이 물건을 많이 수행하는 __construct() 방법을 가지고 있음을 알 수 -

    • Shoes extends BaseShoes :

      나는 것을 가정한다.

      __construct() 메서드를 클래스 중 하나에서 재정의하면 해당 부모 클래스에 정의 된 __construct() 메서드가 재정의됩니다. 여기


      :

      • 당신의 Shoes::__construct() 방법
      • 무시 자체가 존재하지 않는
      • BaseShoes::__construct(), 그래서 몇 가지 매우 중요한 Doctrine-을 할 것으로 보인다 Doctrine_Record::__construct()
      • 과 동일 관련 물건 ;-)

      참고 : PHP 매뉴얼의 Constructors and Destructors 페이지를 인용, 참고로,

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


      그리고 :
      테스트하지,하지만 자신의 생성자에서 부모의 생성자를 호출은 도움이 될 수 :
      자식 클래스 이 생성자를 정의하면 부모 생성자가 암시 적으로 호출되지 않습니다.
      부모 생성자를 실행하려면 하위 생성자 내에서 parent::__construct()을 호출해야합니다.


      정지하는 (!) 참고로, 나는 교리와 모델 클래스에서 자신의 생성자를 정의하는 것은 좋은 생각입니다 확실하지 않다 - 그리고 나는이 같은 사실은, 수행 본 적이 없어 내가 기억하는 한 ...

      그리고 여기가 blog-post on the Doctrine's blog의, 즉 난 것처럼 보입니다 바로 (인용, 강조 광산) :

      [...] 사람이 교리 2 에서 엔티티의 생성자에 대한 질문과 사용 가능 여부.
      나는 이것이 Doctrine 1에 이후로 약 에 대해 쓰는 가치가 있다고 생각한다. 이것은 불가능했다. 생성자 은 안녕하세요. 을 Doctrine으로 내부적으로 사용했습니다. Overriding the Constructor :


      그리고 여기가 관련이 교리의 1.2 설명서의 섹션의

      교리는 Doctrine_Record::__construct() 메소드를 오버라이드 (override)하는 것을 허용하지 않고 다른
      을 [제공합니다 ... ]

    관련 문제