- 普通 - 未处理
[i=s] 本帖最后由 hzg821 于 2010-8-14 17:21 编辑 [/i]大家有没有用过官方提供的视图查询的例子代码如下:
模型FormViewModel类
[color=#0000bb] // Form视图模型
import('ViewModel');
class FormViewModel extends ViewModel {
protected $viewFields = array(
'Form'=>array('id','content','ti
'User'=>array('account'=>'username', '_on'=>'Form.user_id=User.id'),
);
}
?> [/color]
控制器IndexAction类
[color=#0000bb] class IndexAction extends Action{
// 首页
public function index(){
$Form = D("FormView");
// 按照id查出第一个记录
$list = $Form->field('id,ti
$this->assign('list',$list);
//dump($list);
$this->display();
}
}
?> [/color]
大家注意[font=Courier New]$list = $Form->field('id,ti
[font=Courier New]这样写运行后正常,但是如果把 [/font] [font=Courier New]where('Form.id=1')改成where('id=1') 运行后我用dump输出结果为bool(false)运用getLastSql()输出是这样的sql语句SELECT Form.id AS id,Form.ti