are enterprising prepared statements bad? (with php + mysqli)


i conformity enterprising sql i confidence + softened opening prepared statements. i unequivocally wish enterprising prepared statements, complicated since bind_param bind_result accept "fixed" array arguments. i finished an eval() matter around problem. nonetheless i feeling bad idea. here's instance formula i mean



// array where conditions
$param = array('customer_id'=>1, 'qty'=>'2');
$stmt = $mysqli->stmt_init();

$types = ''; $bindparam = array(); $where = ''; $count = 0;

// build enterprising sql param bond conditions
foreach($param $key=>$val)
{
$types .= 'i';
$bindparam[] = '$p'.$count.'=$param["'.$key.'"]';
$where .= "$key = ? ";
$count++;
}

// prepared query -- name * t1 where customer_id = ? qty = ?
$sql = "select * t1 where ".substr($where, 0, strlen($where)-4);
$stmt->prepare($sql);

// arrange bind_param command
$command = '$stmt->bind_param($types, '.implode(', ', $bindparam).');';

// weigh management -- $stmt->bind_param($types,$p0=$param["customer_id"],$p1=$param["qty"]);
eval($command);


is final eval() matter bad idea? i attempted prevaricate formula injection encapsulating values behind non-static name $param.



does anyone have an opinion suggestions? there issues i need wakeful of?



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members