0

I am facing an issue. Please have a look at the 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);    
}

The problem is that the loop only executes a single time. Note that I am using the Phalcon framework.

Timothy
  • 2,004
  • 3
  • 23
  • 29
amol rajhans
  • 21
  • 1
  • 2
  • **WARNING**: When using PDO you should be using [prepared statements](http://php.net/manual/en/pdo.prepared-statements.php) with placeholder values and supply any user data only as arguments on `execute` . In this code you have potentially severe [SQL injection bugs](http://bobby-tables.com/). Refer to [PHP The Right Way](http://www.phptherightway.com/) for advice on how to avoid problem like this. – tadman Jul 29 '16 at 06:32

1 Answers1

0

Your index is id but this does not make sense and therefore you call the stored procedure with the same - undefined - value. Fix the parameter of the stored procedure.

Peter VARGA
  • 4,780
  • 3
  • 39
  • 75