Created
October 16, 2014 01:52
-
-
Save dbarbar/4214fc808cd0bcd8cd3a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
$query = 'SELECT stuff FROM {table} WHERE name = :name and nid IN (:nids);'; | |
$condition = array( | |
"1 ;INSERT INTO {test} SET name = 'test12345678'; -- " => '', | |
'1' => '', | |
); | |
$args = array( | |
':name' => $condition, | |
':nids' => array(5, 6, 7), | |
); | |
foreach (array_filter($args, 'is_array') as $key => $data) { | |
$new_keys = array(); | |
foreach ($data as $i => $value) { | |
$new_keys[$key . '_' . $i] = $value; | |
} | |
$query = preg_replace('#' . $key . '\b#', implode(', ', array_keys($new_keys)), $query); | |
unset($args[$key]); | |
$args += $new_keys; | |
} | |
print 'query: ' . $query . PHP_EOL . 'args: '; | |
var_export($args); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment