我使用这个代码3年了,没有任何问题.今天服务器突然自动升级到新的MySQL版本,导致查询错误:
ERROR - 2023-09-06 23:38:40 --> Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.`package_id`
WHERE `o`.`status` = 3 AND `o`.`user_id` = '278'' at line 2 - Invalid query: SELECT SUM(p.investment_capital) AS abc
FROM `tbl_product_order o LEFT JOIN tbl_package_master p ON p`.`id =` `o`.`package_id`
WHERE `o`.`status` = 3 AND `o`.`user_id` = '278'
ERROR - 2023-09-06 23:38:40 --> Severity: error --> Exception: Call to a member function row_array() on boolean /home2/aekcom/public_html/zac-work/application/libraries/Common.php 94
以下是我的代码:
function getSelectedOneField($select, $table, $where)
{
$this->CI->db->select($select);
$this->CI->db->from($table);
$where2 = substr($where,6);
$this->CI->db->where($where2);
$query = $this->CI->db->get();
$result = $query->row_array();
if ($result) {
return $result[$select];
}
return null; // Return an appropriate value if no result is found
}
function getTotalInvested($user_id=0)
{
$total_invested= 0;
$total_invested = $this->getSelectedOneField("SUM(p.investment_capital) AS abc", "tbl_product_order o LEFT JOIN tbl_package_master p ON p.id = o.package_id", "WHERE o.status = 3 AND o.user_id = '" . $user_id . "'");
if($total_invested !=''){
$total_invested;
}
return CURRENCY.@number_format($total_invested,2);
}
$data['total_invested'] = $this->common->getTotalInvested($this->session->userdata('WDW_MEMBER_LOGIN_ID'));
如何修复此错误?
我有SUM(p.investment_capital)
元零钱要找
SUM(p.investment_capital) AS abc
个