We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 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



43.9k

Hi,

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