I am trying to create stored procedure in Cakephp. I have created Procedure in MYSQL and created global function in AppModel.php to hit procedure. The function in AppModel is sProcedure. Now I have 2 conditions I might have variable to return from procedure or may have direct resultset eg. I have created for Pagination. Though its shooting my procedure but not return any result. Is my function require modification?
public function sProcedure($name = NULL, $inputParameter = array(), $outputParameter = array()) {
$this->begin();
$parameter = "";
$outputParam = "";
foreach ($inputParameter as $params) {
$parameter .= $parameter == "" ? " '$params' " : ", '$params' ";
}
if (count($outputParameter) > 0) {
foreach ($outputParameter as $prm) {
$outputParam .= $outputParam == "" ? " @$prm " : ", @$prm ";
}
}
$parameter = ($outputParam) ? $parameter . ", " . $outputParam : $parameter;
$this->query("CALL `$name`($parameter);");
$result = $this->query("SELECT $outputParam");
$this->commit();
return $result;
}
$sel_data = $this->ArticleNews->sProcedure("update_blank", $input_prameter, $output);
debug($sel_data);
SELECT *
in procedure. How to read response in that case. In that scenerio I won't mention output variables. But If I need specific column like count or any other function I would mention output varibles. Would it work with both. Is it require moderation.