|
Posted by MattMika on 01/04/06 01:28
Hilarion wrote:
> I'm not sure if your solution really works OK. As far as I can see
> it'll return as many rows for each order status as there are orders
> and this will make your script output something like:
>
> Pending - 1, Pending - 1, Pending - 1, Pending - 1, Processing - 1,
> Processing - 1, Processing - 1, Confirmed - 1, Confirmed - 1,
> Cancelled - 1
>
> So it'll work OK only for those statuses which have only one order
> (or have no orders, when it'll output "status name-0").
You are correct. After two weeks away from this I realized after adding many
orders for testing that this is exactly the case.
>
> I'd suggest using your script whith the query replaced by this one:
>
> SELECT
> os.status_id,
> os.status,
> COUNT( o.order_id ) AS num
> FROM
> orders_status AS os LEFT OUTER JOIN
> orders AS o ON o.order_status = os.status_id
> GROUP BY
> os.status_id,
> os.status
> ORDER BY
> os.status_id
>
> and line:
> $num = count($r["order_id"]);
> replaced with:
> $num = intval( $r['num'] );
>
>
>
> Hilarion
Thanx!
Navigation:
[Reply to this message]
|