我從表中獲取某列的總和,查詢是正確的,但是當我試圖在表中顯示它打印零時。以下是我的DAO不顯示從數據庫返回的值
public function getTotal_paid($id)
{
$dbHandler = new dbConfig();
$query="select SUM(payed) from itemsale where custId = $id";
$results = $dbHandler->Query($query);
return $results;
} // End-Function
以下是我的邏輯
public function getTotal_paid($id)
{
$objDAO = new itemsaleDAO();
$results = $objDAO->getTotal_paid($id);
return $results;
} // End-Function
這是我的前端頁面
<table cellpadding="0" cellspacing="0" border="1" align="right">
<tr><th style="height:10px" class="heading_text">Total Paid</th><th style="height:10px width:10px" class="heading_text">Total Remaining</th></tr>
<?
include_once($commonLocation.'Logic/itemSaleLogic.php');
$var= new itemSale();
$object= new itemSaleLogic();
$object1= array();
$object1[0]= new stdClass;
$object1[0]->custId = $_GET['id'];
$var->payed=$object->getTotal_paid($object1[0]);
//$var->remaining=$object->getTotal_rem(6);
echo $var->payed;
echo "<tr><td class=\"inner_text\">".$var->payed."</td>";
//echo "<td class=\"inner_text\">".$var->remaining."</td></tr>";
?>
</table>
對象$ VAR->所許的顯示爲零(忽略的支付拼寫)
老兄,你不能有2個功能與同名(getTotal_paid) – Tom 2012-02-05 19:27:58
@Tom - 如果他們在單獨的類中,他們可能是這樣,否則PHP會拋出解析錯誤。 – nickb 2012-02-05 19:29:05
你是否在課堂上生活第二功能?無法理解你如何接近你的例子。你知道你已經在你的前端頁面硬編碼爲6作爲一個ID? – Nick 2012-02-05 19:30:07