2012-04-04 25 views
0

私はMVCとCodeigniterを初めて使い、クラスを稼働させようとしています。クラスが見つかりません

私のコードを提出する()関数を呼び出すと、私はCodeIgniterの2.1.0と2.2.1教義

を実行しています、私はClass 'Myclass_model' not foundを取得し、含まれる行への参照:$u = new Myclass_model();

を(

012:今、それが延長されたモデル)私のコントローラで

次のコードであるにClass 'Doctrine_Record' not foundを取得し、下部の編集ノートを参照してください。

そして、私の/アプリケーション/モデル/フォルダに私が持っているmyclass.php:

class Myclass extends Doctrine_Record { 

public function setTableDefinition() { 
    $this->hasColumn('username', 'string', 255, array('unique' => 'true')); 
    $this->hasColumn('password', 'string', 255); 
    $this->hasColumn('email', 'string', 255, array('unique' => 'true')); 
} 

public function setUp() { 
    $this->setTableName('testtable1'); 
    $this->actAs('Timestampable'); 
      //$this->hasMutator('password', '_encrypt_password'); 
} 

    protected function _encrypt_password($value) { 
     $salt = '#*[email protected]*%'; 
     $this->_set('password', md5($salt . $value)); 
     //Note: For mutators to work, auto_accessor_override option needs to be enabled. We have already done it, in our plugin file doctrine_pi.php. 

    } 
} 

を私は私の問題はDoctrine_Recordを拡張していると思われます。 doctrine2がインストールされていて、/ application/librariesに/ Doctrine.phpとDoctrineフォルダがあります。 Doctrine_Recordが利用可能で、設定されていることを確認する方法や確認方法はわかりません。

誰かが私にこの問題の解決方法を教えてもらえますか?私のクラスで何か簡単ですか?私のDoctrineのインストール/設定に問題がありますか?

編集:私はそうのようなクラスを呼び出すの提案に従っ:

$this->load->model('Myclass_model','u'); 

そして今モデルは、私はあなたがあなたが含まれていなかった疑いがあるDoctrine_Record

答えて

0

を拡張Class 'Doctrine_Record' not foundを取得していますMyclass.phpファイルまたは不正なパスがあります。 Doctrine拡張機能で問題が発生した場合、エラーには親が記述されます。あなたがそうのようなautoload.phpファイルまたは手動に追加することができたとしても、まだ、include_once('path/to/doctrine_record');

で必ずあなたの新しいクラス内の親ファイルが含まれます

public function submit() { 

     if ($this->_submit_validate() === FALSE) { 
      $this->index(); 
      return;  
     } 

     include_once('/path/to/Myclass.php'); 
     $u = new Myclass(); 
     $u->username = $this->input->post('username'); 
     $u->password = $this->input->post('password'); 
     $u->email = $this->input->post('email'); 
     $u->save(); 

     $this->load->view('submit_success'); 
    } 

またはより良い、あなたはAのようにそれをロードモデル。 Myclass_model :)

public function submit() { 

     if ($this->_submit_validate() === FALSE) { 
      $this->index(); 
      return;  
     } 

     $this->load->model('Myclass_model','u'); 
     $this->u->username = $this->input->post('username'); 
     $this->u->password = $this->input->post('password'); 
     $this->u->email = $this->input->post('email'); 
     $this->u->save(); 

     $this->load->view('submit_success'); 
    } 
+0

私はモデルのようにロードするためにそれを固定するmyclass_model.phpにファイルとクラス名の名前を変更し、現在入手:クラス「Doctrine_Record」が見つかりません(それはDoctrine_Recordを拡張して、私のモデルから) – jeremy

+0

を参照してください私の今すぐ編集する – AlienWebguy

+0

、同じ結果、Doctrine_Recordが見つかりませんでした。質問が更新されました。 – jeremy

関連する問題