我的mysqli数据库有什么问题不计算在内?

时间:2018-02-28 10:46:48

标签: php mysql mysqli

我的数据库计数为零时出现问题,即使mysqli已插入我的函数计数值以显示和计算故障单。

计数仍为零 enter image description here

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();
}

1 个答案:

答案 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;