Posts PDO - Prepared Statements with IN clause
Post
Cancel

PDO - Prepared Statements with IN clause

source http://community.sitepoint.com/t/php-pdo-prepared-statements-with-in-clause/12052

1
2
3
4
5
6
7
8
9
10
11
12
13
		//split by comma
		$arr_tree_levels = explode(",", $_POST["tree_id"]);

		//validation is int!
		//when isnot will be 0 in the array!
		array_walk($arr_tree_levels, function( &$value ) {
				 $value = (int) $value;
		});

		//quote wrap them
		//array_walk($array, function( &$value ) { $value = PDO::quote($value); });

		$trees = get($db,"select tree_id from trees where tree_level_id in (".implode(',',$arr_tree_levels).")", null);

origin - http://www.pipiscrew.com/?p=2072 php-pdo-prepared-statements-with-in-clause

This post is licensed under CC BY 4.0 by the author.
Contents

Trending Tags