Bind Param of PDO Statement Inside Loop

I had a case to use bind parameter of PDO statement inside loop. This was code that I used

[php]
foreach ($this->data as $key => $value) {
$st->bindParam(‘:’ . $key, $value);
}
$st->execute();
[/php]

I executed this code and got surprising result, it didn’t work. Apparently, PDO statement use $value with last looping value. I took a look at PHPDoc for bindParam() and found why this could be happened.
Continue reading