Created
July 7, 2014 05:19
-
-
Save memememomo/89c6b6739a09ce7b5a33 to your computer and use it in GitHub Desktop.
PHP版SQL::MakerでJSON SQL Injectionの対応版を出しました ref: http://qiita.com/uchiko/items/490aee47362ca39d603a
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
$builder = new SQL_Maker(array('driver' => 'mysql', 'strict' => 1)); | |
$builder->select('user', array('*'), array('name' => sql_in(array('foo', 'bar')))); | |
// => SELECT * FROM `user` WHERE `name` IN (?, ?) |
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 | |
//「http://domain/sample4.php?id[TEST]=1」というURLでアクセス | |
// 数値が入る想定だが、 | |
// この場合は array('TEST' => 1) になる。 | |
$id = $_GET['id']; | |
$builder = new SQL_Maker(array( | |
'driver' => 'mysql' | |
)); | |
$table = 'user'; | |
$column = array('id', 'name'); | |
$where = array('id' => $id); | |
list($sql, $binds) = $builder->select($table, $column, $where); | |
// => SELECT `id`, `name` FROM `user` WHERE (`id` TEST ?) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment