Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Undefined Index: And Array_Push

$
0
0
The MySQL query works and returns values, but when I try to use it in my code I get - Undefined index: amount. I thought the indexes would by amount and month as established in my query, but I'm doing something wrong. Any hints or answers would be great! Thanks

Error from the array_push:
Undefined index: amount


Calling the function:
print_r($model->getDirectorBarChartNumbers());


The function:
	public static function getDirectorBarChartNumbers()  {
		//$returnArray = array(Donation::model()->findAll("is_processed = 1"));
		$returnArray = array();
		$pProcessed = Yii::app()->db->createCommand("SELECT SUM( `amount` ) AS 'amount', DATE_FORMAT( DATE, '%b %Y' ) AS 'month' "
													."FROM donation "
													."WHERE `is_processed` =1 "
													."GROUP BY MONTH( DATE ) ASC "
													."LIMIT 3 ");
		foreach ($pProcessed as $processed) {
			array_push($returnArray, array('amount'=>$processed['amount'], 'month'=>$processed['month']));
		 }
		return $returnArray;
}

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>