thinkphp count is not available for group

Source: Internet
Author: User
  $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();// 查询满足要求的总记录数

Unable to get quantity

  $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();// 查询满足要求的总记录数

Can get data

Reply content:

  $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();// 查询满足要求的总记录数

Unable to get quantity

  $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();// 查询满足要求的总记录数

Can get data

Then write it directly.

$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 satisfies the required total number of records

The drawback is that large data volumes can affect efficiency, resulting in too much network IO and resource consumption. Small business words do not have to worry about.

I'm guessing, ha, you try.

$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();//

It is best to print out the executed SQL, the more complex logic with native SQL is best, no need to rigidly.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.