php - passing values to custom find in Model -
i have next custom find in model i'd re-use depending on values passed it.
public function _findactive($state, $query, $result = array()) { if ($state === 'before') { $query['conditions'] = array('webrequest.status' => false, 'webrequest.read_status' => false); $query['contain'] = false; $query['limit'] = 25; $query['order'] = array('webrequest.created' => 'asc'); homecoming $query; } homecoming $result; } i can phone call function controller , paginate results 25 per page. however, able pass limit value function , limit volume per page required. can add together field $limit function parameters ($state, $query, $result = array(), $limit) passed function. if debug @ start of function atif($state === 'before') value remains passed in, function called automatically twice, default gets reset null sec time function called, lose value passed in. there way around this?
try this:
public function _findactive($state, $query, $result = array()) { if ($state === 'before') { $query['conditions'] = array( 'webrequest.status' => false, 'webrequest.read_status' => false ); $query['contain'] = false; $query['limit'] = 25; $query['order'] = array('webrequest.created' => 'asc'); homecoming $query; } elseif ($state == 'after') { homecoming $results; } }` php cakephp
No comments:
Post a Comment