yii对象dataProvider的读取信息问题
时间:2021-07-01 10:21:17
帮助过:19人阅读
public function actionIndex()
{
$dataProvider=Export::model()->findAllBySql("select id,BaiduLat,BaiduLon from tablename where id < 3");
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
这是控制器中的方法,现在想在index.php把$dataProvider的数据给读取出来,放在数组里。 print_r($dataProvider); 输出得到以下,
Array ( [0] => Export Object ( [_new:CActiveRecord:private] => [_attributes:CActiveRecord:private] => Array ( [id] => 1 [BaiduLat] => 31.262788 [BaiduLon] => 121.630306 ) [_related:CActiveRecord:private] => Array ( ) [_c:CActiveRecord:private] => [_pk:CActiveRecord:private] => 1 [_alias:CActiveRecord:private] => t [_errors:CModel:private] => Array ( ) [_validators:CModel:private] => [_scenario:CModel:private] => update [_e:CComponent:private] => [_m:CComponent:private] => ) [1] => Export Object ( [_new:CActiveRecord:private] => [_attributes:CActiveRecord:private] => Array ( [id] => 2 [BaiduLat] => 31.263184 [BaiduLon] => 121.630395 ) [_related:CActiveRecord:private] => Array ( ) [_c:CActiveRecord:private] => [_pk:CActiveRecord:private] => 2 [_alias:CActiveRecord:private] => t [_errors:CModel:private] => Array ( ) [_validators:CModel:private] => [_scenario:CModel:private] => update [_e:CComponent:private] => [_m:CComponent:private] => ) )
print_r($dataProvider);得到上面这些东西,请问,如何把多个BaiduLat和BaiduLon的信息给取出来,放在一个数组中,便于后续地图标注使用,谢谢
回复讨论(解决方案)
所有的成员都是 private (私有)的,在外部不能访问
所以 Export 类一定存在有处理这些私有成员的方法,你可以仿写一下