并再模板中输出
$db = M('table'); //表名
$where = array( //条件数组
'id' => 2,
);
$rs = $db->where($where)->select(); //查询, 用find()只能查出一条数据,select()多条
$this->assign('datalist',$rs); //模板赋值
$this->display();//输出到模板
$where = array( //条件数组
'id' => 2,
);
$rs = $db->where($where)->select(); //查询, 用find()只能查出一条数据,select()多条
$this->assign('datalist',$rs); //模板赋值
$this->display();//输出到模板
温馨提示:答案为网友推荐,仅供参考
第1个回答 2015-03-30
$ret = M('表名')->where('条件')->field(' 要查的字段')->find();