We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

How to execute store procedure in loop.

Hi Team,

I am facing one issue. Please have a look on below code.

// $data having 1000 entries

foreach($data as $key=>$value) {

$resultStore = $this->db->query("call get_parents(" . $value['id'] . ")");

$dataStore = $resultStore->fetchAll(PDO::FETCH_ASSOC);


But this loop execute only one time.

Please let me know if anyone have solution for this.

Thanks, Amol



on each loop step $resultStore and $resultStore are overwriten by te new db queries. So, you have only one result in them.