午灬夏 发表于 2012-4-12 11:57:30

如何自动加载公用的model ?

1、
$autoload['model'] = array('siteinfo');

2、
在application/models/siteinfomodel.php
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Siteinfomodel extends CI_Model{
   
    function __construct(){
      parent::__construct();
    }
    //获取站点信息
    function getsiteinfo(){
      $sql = "SELECT * FROM le_system WHERE 1";
      $info = $this->db->result_array();
      return $info;
    }
}
?>
报:Unable to locate the model you have specified: siteinfo
这是个获取站点基本信息的model ,很多地方都需用到! 不知道该使用?

Hex 发表于 2012-4-12 12:27:01

没看手册。
应该是
$autoload['model'] = array('siteinfomodel');

大道达人 发表于 2012-4-12 13:07:03

config 下autoload.php添加下
或者
用spl_autoload
但是需要定义下

午灬夏 发表于 2012-4-12 13:08:30

Hex 发表于 2012-4-12 12:27 static/image/common/back.gif
没看手册。
应该是
$autoload['model'] = array('siteinfomodel');

谢谢 Hex 老大! 正解!
页: [1]
查看完整版本: 如何自动加载公用的model ?