【发布时间】:2013-06-12 03:45:51
【问题描述】:
我用它来计算数据库中的所有活跃用户,就像它应该的那样工作:
$ouser = new User;
$data['users_active'] = $ouser->where(array('active'=>1))->count();
现在我还想使用(相同的)对象来统计所有不活跃用户,因此我想使用这个:
$ouser = new User;
$data['users_active'] = $ouser->where(array('active'=>1))->count();
$data['users_inactive'] = $ouser->where(array('active'=>0))->count();
但这似乎不起作用。首先清除对象也不起作用:
$ouser = new User;
$data['users_active'] = $ouser->where(array('active'=>1))->count();
$ouser->clear();
$data['users_inactive'] = $ouser->where(array('active'=>0))->count();
我怎样才能重用同一个对象,在这种情况下进行计数?
【问题讨论】:
标签: php codeigniter-datamapper