PDO - Prepared Statements with IN clause

Costas

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

JavaScript:
		//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);
 
Top