CakePHP requestAction()
Need to access a controller method from the view?
View:
$quantity = $this->requestAction(array(
'controller' => 'articles',
'action' => 'getRowQuantity'),
array('id' => $current_id));
Controller:
public function getRowQuantity($id =0)
{
$id = $this->params['id']; // remember!
$total = $this->Article->ArticleTransaction->find('all', array(
'fields' => array('sum(ArticleTransaction.quantity) as TOTAL'),
'conditions' => array('ArticleTransaction.service_id' => $id)));
$total_available = $total[0][0]['TOTAL'];
return $total_available;
}
Written by Fabrizio Soppelsa
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#