本帖最后由 书君 于 2009-7-28 23:46 编辑
谢谢HEX。
顺便再弱弱的问个问题!
这是我写的model:
<?php
class Muser extends Model {
var $table;
function Muser(){
parent::Model();
$this->table ='user';
}
function selectArray($orderby){
$sql="select * from ".$this->table. "order by ".$orderby;
$query = $this->db->query($sql);
return $query->result_array();
}
}
?>
这是我写的控制器:
<?php
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
}
function index()
{
$this->load->model('muser');
$this->Date['a']=$this->muser->selectArray('id DESC');
$this->load->view('firstCi',$this->Date);
}
}
?>
结果出现这样的错了:
-------------------------------------------------------------------------
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Muser:: $db
Filename: models/muser.php
Line Number: 10
------------------------------------------------------------------------
Fatal error: Call to a member function query() on a non-object in D:\AppServ\www\MyCi\system\application\models\muser.php on line 10
不是这样查询的么? |