<code> $count = $order->where($con) ->join("LEFT JOIN x_goods ON x_goods.goods_id = x_order.order_goodsid") ->order("order_createtime desc") ->group("order_no") ->count();// 查询满足要求的总记录数</code>
Unable to obtain quantity
<code> $count = $order->where($con) ->join("LEFT JOIN x_goods ON x_goods.goods_id = x_order.order_goodsid") ->order("order_createtime desc") ->group("order_no") ->select();// 查询满足要求的总记录数</code>
Data can be obtained
<code> $count = $order->where($con) ->join("LEFT JOIN x_goods ON x_goods.goods_id = x_order.order_goodsid") ->order("order_createtime desc") ->group("order_no") ->count();// 查询满足要求的总记录数</code>
Unable to obtain quantity
<code> $count = $order->where($con) ->join("LEFT JOIN x_goods ON x_goods.goods_id = x_order.order_goodsid") ->order("order_createtime desc") ->group("order_no") ->select();// 查询满足要求的总记录数</code>
Data can be obtained
Then write it directly as
$count = count($order->where($con) ->join("LEFT JOIN x_goods ON x_goods.goods_id = x_order.order_goodsid") ->order("order_createtime desc") -> group("order_no") ->select());//Query the total number of records that meet the requirements
The disadvantage is that large data volumes will affect efficiency, resulting in excessive network IO and resource consumption. If it’s a small business, you don’t have to worry too much.
I was just guessing, you try it
<code class="php">$count = $order->where($con) ->join("LEFT JOIN x_goods ON x_goods.goods_id = x_order.order_goodsid") ->order("order_createtime desc") ->group("order_no") ->field("count(*)") ->select();//</code>
It is best to print out the executed SQL and take a look. For more complex logic, it is best to use native SQL. There is no need to be rigid.