Php代码:
//可见
$c = new CDbCriteria();
$c->join = "JOIN idc_user on t.id=idc_user.user_id";
$c->condition = "idc_user.idc_id=$idc_id";
//运行后
object(CDbCriteria)#98 (12) { ["select"]=> string(1) "*" ["distinct"]=> bool(false) ["condition"]=> string(17) "idc_user.idc_id=6" ["params"]=> array(0) { } ["limit"]=> int(-1) ["offset"]=> int(-1) ["order"]=> string(0) "" ["group"]=> string(0) "" ["join"]=> string(38) "JOIN idc_user on t.id=idc_user.user_id" ["having"]=> string(0) "" ["with"]=> NULL ["alias"]=> NULL }
//User::model()->with('Idcs')->findAll($c)
二、mergeWith的情况
Php代码:
//在ActiveRecord中,增加条件限制 $this->getDbCriteria()->mergeWith(array( 'condition'=>"idc_id IN ($ids)", ));
更多关于Yii相关内容感兴趣的读者可查看本站专题:《Yii框架入门及常用技巧总结》、《php优秀开发框架总结》、《smarty模板入门基础教程》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。







