数据库是 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);
结果为 空 数据库里我添加数据了 请问这是什么情况
{
// 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);
结果为 空 数据库里我添加数据了 请问这是什么情况
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货