$count = self::$redis->lLen('server_name');
while($count > 0){
$server_name = self::$redis->rPop('server_name');
$mytime = self::$redis->rPop('mytime');
$status = self::$redis->rPop('status') ;
$client_name = self::$redis->rPop('client_name');
$content = self::$redis->rPop('content');
/*
客服对话是否解决和等级评分以 用户为主题重新设立一张表
*/
if(self::$redis->sIsMember('kefus',$server_name)){
self::$redis->sRem('kefus',$server_name);
$sql = " SELECT servername FROM kefus WHERE servername = '$server_name'; ";
self::$mysqli->query($sql);
if(self::$mysqli->affected_rows == 0 && $server_name != 'robot'){
$sql = " INSERT INTO kefus (servername,nickname) VALUES('$server_name','$server_name'); ";
self::$mysqli->query($sql);
}
}
if($server_name == 'robot'){
$sql = " INSERT INTO robot (clientname,mytime,content,status,rank,isfinish) VALUES('$client_name','$mytime','$content','$status',5,1); ";
self::$mysqli->query($sql);
continue;
}
// $sql = " INSERT INTO users(client,rank,isfinish)
// VALUES('client',1,1); ";
// self::$mysqli->query($sql);
$sql = " CREATE TABLE IF NOT EXISTS `$server_name` (
id INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
mytime VARCHAR(12) NOT NULL,
status INT(2) NOT NULL,
clientname VARCHAR(30) NOT NULL,
content VARCHAR(255) NOT NULL
); ";
self::$mysqli->query($sql);
$sql = " INSERT INTO `$server_name` (mytime,status,clientname,content) VALUES ('$mytime','$status','$client_name','$content'); ";
self::$mysqli->query($sql);
$count--;
}
就因为自己没有写$count--,找bug找了半天,真的半天!细节决定成败,基础一定要打扎实!