今天我的脚本有一些问题,我无法准备查询并且脚本不会重新运行任何错误:
表结构(哎呀,错误的表,已更正):
CREATE TABLE IF NOT EXISTS `razorphyn_support_users` (
`id` BIGINT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL,
`mail` VARCHAR(50) NOT NULL,
`password` VARCHAR(200) NOT NULL,
`reg_key` VARCHAR(260) NOT NULL,
`tmp_password` VARCHAR(31) NULL,
`ip_address` VARCHAR(50) NOT NULL,
`status` ENUM('0','1','2','3','4') NOT NULL DEFAULT '3',
`holiday` ENUM('0','1') NOT NULL DEFAULT '0',
`assigned_tickets` INT(5) UNSIGNED NOT NULL DEFAULT 0,
`solved_tickets` BIGINT(11) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY(`mail`))
ENGINE=MyISAM
DEFAULT CHARSET=utf8
AUTO_INCREMENT=55;
无法准备的字符串:
$query = "SELECT `id` FROM ".$SupportUserTable."
WHERE `status`='2' AND `holiday`='0' AND MIN(`assigned_tickets`)
ORDER BY `solved_tickets` ASC" ;
完整的代码(实际上这只是其中的一部分,$stmt
已经开始工作了,基本上它已经连接了):
file_put_contents('ok.txt','');
$query = "SELECT `id` FROM ".$SupportUserTable."
WHERE `status`='2' AND `holiday`='0' AND MIN(`assigned_tickets`)
ORDER BY `solved_tickets` ASC" ;
$prepared = $stmt->prepare($query);
if($prepared){
file_put_contents('ok2.txt','');
if($stmt->execute()){
file_put_contents('ok3.txt','');
$stmt->store_result();
$result = $stmt->bind_result($id);
file_put_contents('eafv.txt','id: '.$id);
if($stmt->num_rows>0){
$query = "UPDATE ".$SupportTicketsTable." SET operator_id=?
WHERE id=? ";
if($prepared = $stmt->prepare($query)){
if($stmt->bind_param('ii', $id,$tkid)){
if($stmt->execute()){
echo json_encode(array(0=>'Created'));
}
else
echo json_encode(array(0=>mysqli_stmt_error($stmt)));
}
else
echo json_encode(array(0=>mysqli_stmt_error($stmt)));
}
else
echo json_encode(array(0=>mysqli_stmt_error($stmt)));
}
else
echo json_encode(array(0=>'No Operator Available'));
}
else
echo json_encode(array(0=>mysqli_stmt_error($stmt)));
}
else
echo json_encode(array(0=>$stmt->error));