重複の可能性:
非オブジェクトでのメンバー関数 get() の呼び出し
データベース ライブラリを自動ロードします。
これが私のコントローラーです
class Orders extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('orders_model');
}
public function index()
{
echo $this->orders_model->test();
$data['orders'] = $this->orders_model->get_orders();
ここに私のモデルがあります
class Orders_model extends CI_Model {
public function __construct()
{
parent::__construct();
}
public function get_orders($slug = FALSE)
{
if ($slug === FALSE)
{
$query = $this->db->get('table1');
return $query->result_array();
}
$query = $this->db->get_where('table1', array('numtest' => $slug));
return $query->row_array();
}
public function test()
{
$text = "return test";
return $text;
}
トラブルシューティングの目的で、コードをモデルからコントローラーに移動し、コードを正常に実行しました。どういうわけか、モデルから get() 呼び出しを実行しようとすると機能しません。また、モデル内から test() 関数を呼び出すと、正常に機能します。