In a project that I\'m about to wrap up, I\'ve written and implemented an object-relational mapping solution for PHP. Before the doubters and dreamers cry out \"how on earth
call_user_func_array(array(&$stmt, 'bindparams'), $array_of_params);
Didn't work for me in my environment but this answer set me on the right track. What actually worked was:
$sitesql = '';
$array_of_params = array();
foreach($_POST['multiselect'] as $value){
if($sitesql!=''){
$sitesql .= "OR siteID=? ";
$array_of_params[0] .= 'i';
$array_of_params[] = $value;
}else{
$sitesql = " siteID=? ";
$array_of_params[0] .= 'i';
$array_of_params[] = $value;
}
}
$stmt = $linki->prepare("SELECT IFNULL(SUM(hours),0) FROM table WHERE ".$sitesql." AND week!='0000-00-00'");
call_user_func_array(array(&$stmt, 'bind_param'), $array_of_params);
$stmt->execute();