Calling same model function with different parameters not returning values
Soooo....long time reader first time poster. For the first time, can't find the answer!
I've got a model that returns an array o开发者_JAVA百科f results (working). Then I loop through the results with a foreach and append the array with additional values from a second function in my model. Problem is that only the first of my several function calls return any results. The function get_offering_total() only returns the value for the first listed call (cash). This is returning the correct value, but any subsequent attempts to use the same function returns nothing. A var_dump shows that the array is structured correctly on the output, but the values are all null. Is there an issue with calling the same model method with different parameters? Something needs to be cleared/reset?
Here's the code...
//$data['offerings'] stores the results from my first query
foreach( $data['offerings'] as $key => $value ) {
//Set filters
$cash_filter = array( 'method' => '5' ); $checks_filter = array( 'method' => '6' );
//Get totals
$data['offerings'][$key]['cash'] = $this->model_records->get_offering_total( $value['offering_id'], $cash_filter); $data['offerings'][$key]['checks'] = $this->model_records->get_offering_total( $value['offering_id'], $checks_filter);
...other stuff... }
Thanks for your help!
Here's a simple test to see if all the code you wrote is correct. Surround everything in your function (in the model) within a try/catch block, and see if it throws any kind of exception. You'd be surprised how many exceptions get thrown but PHP doesn't show them because you have error reporting off in your PHP config. You can do the same for the two lines on which you call the method in your controller and see if they are all good.
PHP Exceptions Reference
精彩评论