-2
prepare文は正常に動作します。しかし、もし私が準備文のためにベロー関数を使うと、それは空の結果を返します。 マイコード:phpのprepare文の関数は、ローカルサーバは正常に動作しますが、リモートサーバは動作しません。
//prepare statement * all column
function prepare_select_stmt($link, $sql, $param_type, array $param){
$num_param = strlen($param_type);
$link->stmt_init();
$stm = $link->prepare($sql);
$bindParam = '$stm->bind_param($param_type,';
for($i=0;$i<=$num_param-1;$i++){
$bindParam.='$param['.$i.'],';
}
$bindParam = rtrim($bindParam,',').');';
eval($bindParam);
//$stm->bind_param($param_type, $param);
$stm->execute();
$stm->store_result();
$meta = $stm->result_metadata();
$bindResult = '$stm->bind_result(';
while($columnName = $meta->fetch_field()){
$bindResult .= '$result["'.$columnName->name.'"],';
}
$bindResult = rtrim($bindResult,',').');';
eval($bindResult);
$numRows= $stm->num_rows();
if($numRows>0){
$stm->fetch();
return array($numRows,$result);
}else{
return array($numRows,array()); //empty array() means no result
}
$stm->close();
}
この関数は、ローカルサーバーで正常に動作しますが、リモートサーバーにゼロ結果を返します。 なぜですか?
これを探している可能性があります。http://stackoverflow.com/questions/38031732/wrapping-a-prepared-statement-in-a-function/38031840#38031840 – Chay22
エラーログを追加してください。 –
エラーログを追加する方法@Govind –