欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

yii对象dataProvider的读取信息问题

程序员文章站 2023-12-30 08:28:40
...
public function actionIndex()
{
$dataProvider=Export::model()->findAllBySql("select id,BaiduLat,BaiduLon from tablename where id
$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 类一定存在有处理这些私有成员的方法,你可以仿写一下

上一篇:

下一篇: