好的,所以我的查询是这样的:
select distinct `rate_id`, `p_id`, p_rate from shipping_rates inner join products_to_categories ptc inner join customers_basket cb on ptc.products_id = cb.products_id where cb.customers_id='1' and p_status = '1' and p_free = '0' group by p_id
返回
rate_id p_id p_rate
1 1 10.00
2 22 11.00
这就是我想要的但是当我将它添加到一个数组时
$p_rate[] = $sInfo->p_rate;
$rate = array_sum($p_rate);
这会返回 10.00 而不是 21.00
顺便说一下,这是我的 objectInfo 类代码
function objectInfo($object_array) {
reset($object_array);
while (list($key, $value) = each($object_array)) {
$this->$key = tep_db_prepare_input($value);
}
}
}
}
下面的代码是
$sRate = tep_db_fetch_array($status_query);
if ($sRate !=''){//error checking for empty query
$sInfo = new objectInfo($sRate);
}
trp_db_fetch_array() 只是一个调用 mysql_fetch_array 的函数