Last active
September 5, 2022 05:58
-
-
Save asgrim/22859d7af570c33ee52f34564c24afb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$thingsToBind = [ | |
[ | |
'value' => '123', | |
'param' => 'first', | |
], | |
[ | |
'value' => '321', | |
'param' => 'second', | |
], | |
]; | |
foreach ($thingsToBind as $bindParam) { | |
$value = $bindParam['value']; | |
/** | |
* Since `$value` is passed by reference, each iteration the `$value` is overwritten and the previous bind is affected | |
* | |
* MUCH WOW | |
*/ | |
$sth->bindParam($bindParam['param'], $value, $bindParam['type']); | |
$debugParams[$bindParam['param']] = $value; | |
} | |
/** | |
* In effect, the binds are now: | |
* first - 321 | |
* second - 321 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment