在where子句中传递查询数据(数组)时进行数组到字符串转换

时间:2015-09-29 18:56:49

标签: php mysql arrays codeigniter

在where子句中传递查询数据(数组)时进行字符串转换的数组。我试过了,所以现在我要害怕了。我试图在->result()中将->row()替换为$ord = "query"但是没有。我请任何身体帮助我,我现在该怎么办。谢谢。这是我的代码。

public function order_join()
{
$ord = $this->db->query('SELECT `Order_ID` FROM `order` WHERE `DateTime` = (SELECT MAX(DateTime) FROM `order`)')->result(); 
$query = "SELECT a.Order_ID, a.User_ID,a.Pro_ID, a.Price as Total_Amount, SUM(b.Amount) 
            as Total_Amount_Recieved, (a.Price - SUM(b.Amount)) AS Remaining_Amount 
            FROM `order` a JOIN `payments` b ON a.Order_ID = b.Order_ID WHERE a.Order_ID = '".$ord."' ";
return $this->db->query($query)->row();

} 这是错误的。 Error

0 个答案:

没有答案