2016-08-09 1 views
0

「指定したモデルを見つけることができません:設定」 ここに私の設定モデルがあり、ファイル名も設定です。 localhostで動作していますが、サーバにアップロードした後にエラーが表示されます。ウェブリンク:「指定したモデルを見つけることができません:設定」codeigniterのローディングモデル

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 
Class Settings extends CI_Model 
{ 
     public function __construct() 
    { 
     parent::__construct(); 
    } 

    public function get_settings($code) 
    { 
     CI::db()->where('code', $code); 
     $result = CI::db()->get('settings'); 

     $return = []; 
     foreach($result->result() as $results) 
     { 
      $return[$results->setting_key] = $results->setting; 
     } 
     return $return; 
    } 

    /* 
    settings should be an array 
    array('setting_key'=>'setting') 
    $code is the item that is calling it 
    ex. any shipping settings have the code "shipping" 
    */ 
    public function save_settings($code, $values) 
    { 
     //get the settings first, this way, we can know if we need to update or insert settings 
     //we're going to create an array of keys for the requested code 
     $settings = $this->get_settings($code); 

     //loop through the settings and add each one as a new row 
     foreach($values as $key=>$value) 
     { 
      //if the key currently exists, update the setting 
      if(array_key_exists($key, $settings)) 
      { 
       $update = array('setting'=>$value); 
       CI::db()->where('code', $code); 
       CI::db()->where('setting_key',$key); 
       CI::db()->update('settings', $update); 
      } 
      //if the key does not exist, add it 
      else 
      { 
       $insert = array('code'=>$code, 'setting_key'=>$key, 'setting'=>$value); 
       CI::db()->insert('settings', $insert); 
      } 
     } 
    } 

    //delete any settings having to do with this particular code 
    public function delete_settings($code) 
    { 
     CI::db()->where('code', $code); 
     CI::db()->delete('settings'); 
    } 

    //this deletes a specific setting 
    public function delete_setting($code, $setting_key) 
    { 
     CI::db()->where('code', $code); 
     CI::db()->where('setting_key', $setting_key); 
     CI::db()->delete('settings'); 
    } 
} 
+0

私はすでに: "あなたが指定したモデルを見つけることができません:設定" –

+0

あなたはモーダルクラスを拡張していません –

+0

は私のコードを更新しましたが、 –

答えて

0

あなたは道以下のモデルを作成しようとすることができます。

Settings_model.php

http://layakdesign.co.nf//application/models/settings_model.php

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 


class Settings_model extends CI_Model 
{ 
    public function __construct() 
    { 
     parent::__construct(); 
    } 
    ... 

} 
?> 

特定のコントローラファイルでモデルをロードします。

<?php 
    defined('BASEPATH') OR exit('No direct script access allowed'); 

    class Setting extends CI_Controller { 

     public function __construct() { 
      parent::__construct(); 
      $this->load->model('settings_model'); 
     } 
} 
    ?> 
+0

おかしなこと:) –

0

それは、クラス名とファイル名の問題で、クラス名に小文字を作る示すhttp://layakdesign.co.nf/

エラーどのように私はこの問題を解決することができます同様に、ファイル名

class settings extends CI_Model 
{ 
... 
} 

とファイル名あまりのsettings.php

+0

もう一度同じエラーが発生しました –

+0

私にコードを表示しますか?ソリューションのための –

0

モデル関数に同じ名前をdecalreしなければならないものは何でもあなたのファイル名

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

のようなコードを書くよりも、 のsettings.phpお使いのモデルのファイル名の場合。