我在 PHP 中有一个函数,它应该在 MySQL IN 语句中绑定这么多变量,即数组中的变量。我的问题是变量和键正在更改,但函数仅绑定最后一个值 n 次。
我不知道问题出在哪里...
这是我的类方法:
public function getOtListByOtNumbers($conditions){
$data_array = $conditions[SEARCH_OT];
# To find last key (remove coma)
$quantity = count($data_array);
$marks = '';
# Bind name string && rewriting value as integer
foreach ($data_array as $key => $value){
$i = $key+1;
if ($i == $quantity){
$marks .= ':key'.$i;
}
else {
$marks .= ':key'.$i.', ';
}
}
# Query
$sql="
SELECT
c_int_id,
c_ot,
c_tickets_amount,
c_basket_value,
c_person,
c_company,
c_city,
c_package_number,
c_delivery_method,
c_ot_date,
c_email,
c_phone,
c_comment, …Run Code Online (Sandbox Code Playgroud)