您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

yii relations求救

2025/11/29 11:28:09发布13次查看
数据库是 mysql myisam
现有已表 train 培训表
train_people 参加培训的人员表
一个train对应多个 train_people 通过 train的主键 train_id关联的 train_people 里面也有个train_id
在train model里面
public function relations()
    {
        // note: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
       return array(
            'people'=>array(self::has_many, 'trainpeople', 'train_id'),
       );
   }
这样写的
查询语句
$model = new train();
        $model_user = new user();
        $criteria = new cdbcriteria;
        //$criteria->condition = ;
        $criteria->order = 'add_time desc';
        $criteria->select = '*';
        $count = $model->count($criteria);
        $pager = new cpagination($count);
        $pager->pagesize = 10;
        $pager->applylimit($criteria);
        $lists = $model->with('people')->findall($criteria);
        var_dump($lists->people);
结果为 空 数据库里我添加数据了 请问这是什么情况
回复讨论(解决方案) yii::app()->db()->createcommand()->select(列)->from(表)->where()->limit()->order()->queryall()

yii::app()->db()->createcommand()->select(列)->from(表)->where()->limit()->order()->queryall()

虽然不是我想要的,问题已经解决了,这么长时间只有你回答感。非常感谢没有鄙视像我这样问一些弱智的问题
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product