[Codeigniter-users] modelを呼べない

Back to archive index

Taro Yamashita taro****@panth*****
2009年 5月 31日 (日) 16:51:16 JST


Taroです。

ファイル名が[modeltest.php]なので、

$this->load->model('modeltest');

ではないでしょうか??
「徹底入門」には、モデルの読み込みについて

>第1引数には、PHPの拡張子(.php)を抜いた
>モデルファイル名、つまりモデルクラス名を指定します。

とありました。

Taro

ikari****@ecoin***** さんは書きました:
> 碇です
> 
> いろいろいじりすぎて混乱してました
> Amanoさんのメールに返信しましたが
> ikari @ ubuntu-desktop:/var/www/ci/system/application/models$ cat modeltest.php
> class Modeltest extends Model{
>         function __construct(){
>                 parent::Model();
>         }
>         function getdata(){
>                 return "test";
>         }
> }
> ikari @ ubuntu-desktop:/var/www/ci/system/application/models$ cat ../controllers/test.php
> <?php
> class Test extends Controller {
> 
>         function __construct()
>         {
>                 parent::Controller();
>         }
> 
>         function index()
>         {
>                 $this->load->model('Modeltest');
>                 //$a = Testmodel->get_data();
>                 echo "$a";
>         }
> }
> 
> となっていますがModeltestを見つけられないようです
> 
> 
> 
> 
> 
> On Sun, 31 May 2009 16:30:29 +0900
> Taro Yamashita <taro****@panth*****> 様wrote:
> 
>> 碇さん
>>
>> こんにちは。Taroと申します。
>>
>>> class ModelTest extends Model
>> に対して、
>>
>>> $this->load->model('Testmodel')
>> となっているからではないでしょうか??
>> model名をどちらかに統一すればOKのような気がします。
>>
>> Taro
>>
>> ikari****@ecoin***** さんは書きました:
>>> 碇と申します
>>>
>>> DocumentRootにciとしてCI1.7を展開しました
>>>
>>> /var/www/ci/system/application/config/config.php
>>> $config['base_url']     = "http://example.jp/ci/"
>>> に変更
>>>
>>> /var/www/ci/system/application/controllers/test.php
>>>
>>> <?php
>>> class Test extends Controller {
>>>
>>>         function __construct()
>>>         {
>>>                 parent::Controller();
>>>         }
>>>
>>>         function index()
>>>         {
>>>                 $this->load->model('Testmodel');
>>>                // $a = Testmodel->get_data();
>>>                 echo "$a";
>>>         }
>>> }
>>>
>>> /var/www/ci/system/application/models/modeltest.php
>>> class ModelTest extends Model{
>>>         function __construct(){
>>>                 parent::Model();
>>>         }
>>>         function getdata(){
>>>                 return "test";
>>>         }
>>> }
>>>
>>> これで
>>> http://example.jp/ci/index.php/test
>>> を呼ぶと
>>> Fatal error: Class 'Testmodel' not found in /var/www/ci/system/libraries/Loader.php on line 184
>>> となります
>>>
>>> 何をチェックすればいいでしょうか?
>>>
>> _______________________________________________
>> Codeigniter-users mailing list
>> Codei****@lists*****
>> http://lists.sourceforge.jp/mailman/listinfo/codeigniter-users
> 




Codeigniter-users メーリングリストの案内
Back to archive index