我的数据库计数为零时出现问题,即使mysqli
已插入我的函数计数值以显示和计算故障单。
public static function getTicketCount() {
$mysqli = dbConnect();
$sql = "select count(*) as numberOfTickets
from tickets
where user = '$user' AND assigneduser ='$assigneduser' ";
$result = $mysqli->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
return $row['numberOfTickets'];
}
} else {
echo "0";
}
$mysqli->close();
}
答案 0 :(得分:-1)
只需将let frontNavigationController:UINavigationController
let rearNavigationController:UINavigationController
let revealController = SWRevealViewController()
var mainRevealController = SWRevealViewController()
let menuTable = self.storyboard?.instantiateViewController(withIdentifier: "MenuViewController")as! MenuViewController
let homepage = self.storyboard?.instantiateViewController(withIdentifier: "HomeViewController") as! HomeViewController
frontNavigationController = UINavigationController(rootViewController: homepage)
rearNavigationController = UINavigationController(rootViewController: menuTable)
rearNavigationController.setNavigationBarHidden(true, animated: false)
revealController.frontViewController = frontNavigationController
revealController.rearViewController = rearNavigationController
revealController.delegate = self
mainRevealController = revealController
UIApplication.shared.delegate!.window?.rootViewController = mainRevealController
替换为count(*)
即可。否则,您应该为其运行fetch assoc或fetch行。
正确的查询将是:
*
这样您的代码就会立即生效。
请在开头添加此项以使您的行计数变量起作用:
select * from tickets where user = '$user' AND assigneduser ='$assigneduser' ";
在这一行之后你有:
$numberOfTickets = $result->num_rows;