YII PHP nested foreach error -


i have error here want combine data 2 query using nested foreach , save data in array called result there error trying property of non-object in these part of code : 'id_product'=>$detail_result->id, can me?

i'm still new using yii framework php

here code

$result = array();

        $criteria = new cdbcriteria;         $criteria->condition = 'date_time >= :start , date_time <= :end';         $criteria->order = 'date_time';         $criteria->params = array(':start' => $_post['tanggal']['start'] ,':end' => $_post['tanggal']['end']);          $checkin = checkin::model()->findall($criteria);          foreach($checkin $entry) {             $sql = "select * check_in_detail id_check_in = $entry->id";             $detail_results = yii::app()->db->createcommand($sql)->queryall();              foreach($detail_results $detail_result)             {                  $result [] = array(                      'tanggal'=>$entry->date_time,                     'id_product'=>$detail_result->id,                      'total'=>$detail_result->total,                      'id_distributor'=>$entry->iddistributor->name,                      'other'=>$entry->description,                  );              }          } 

is can help? thanks

the problem in accessing $detail_result variable,

function queryall() bring array of arrays, not array of objects!

change code below :

             $result [] = array(                  'tanggal'=>$entry['date_time'],                  'id_product'=>$detail_result['id'],                  'total'=>$detail_result['total'],                  ...                ); 

(btw var_dump variable see contains)


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -