P粉7970046442023-08-18 09:57:17
$costTotal
包含了数据库查询的结果,它不是一个字符串,但你在使用 echo
。要将结果作为字符串输出,你需要从查询结果中获取数据。
$connection = connexion(); $query = "SELECT SUM(product_cost) as total FROM product"; $result = $connection->query($query); $data = $result->fetch(PDO::FETCH_ASSOC); $costTotal = $data['total']; echo $costTotal;