我在订单表中添加了一个新列(shopper_id)我试图获取具有新列条件的数据,但结果返回空 查询是正确的,当我直接执行它时,它返回正确的结果
打开购物车公式
SELECT o.order_id, o.firstname, o.lastname, os.name as status, o.date_added,o.shopper_id, o.total, o.currency_code, o.currency_value FROM `medrahoc_order` o LEFT JOIN medrahoc_order_status os ON (o.order_status_id = os.order_status_id) WHERE o.store_id = '0' AND o.order_status_id = '1' AND os.language_id = '1' AND ( o.shopper_id = NULL OR o.shopper_id = 0 ) ORDER BY o.order_id DESC
下面是我的mysql查询 -
public function getOrdersByStore($store_id, $status = null) {
if (isset($status)) {
$sql = "SELECT o.order_id, o.firstname, o.lastname, os.name as status, o.date_added,o.shopper_id as shopper_id , o.total, o.currency_code, o.currency_value FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_status os ON (o.order_status_id = os.order_status_id) WHERE o.store_id = '" . (int) $store_id . "' AND o.order_status_id = '" . (int) $status . "' AND os.language_id = '" . (int) $this->config->get('config_language_id') . "' AND o.shopper_id = '0' ORDER BY o.order_id DESC";
} else {
$sql = "SELECT o.order_id, o.firstname, o.lastname, os.name as status, o.date_added, o.total, o.currency_code, o.currency_value FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_status os ON (o.order_status_id = os.order_status_id) WHERE o.store_id = '" . (int) $store_id . "' AND o.order_status_id > '0' AND os.language_id = '" . (int) $this->config->get('config_language_id') . "' ORDER BY o.order_id DESC";
}
$query = $this->db->query($sql);
return $query->rows;
}
我的模特函数
9.6 x 10²
9.6 x 10¹²