function count_user_order($user_list_str, $limit = 4, $times = 1){ static $result = array('users_count'=>array(), 'order_number'=>array(), 'order_amount'=>array()); $sql = 'select user_id from '.$globals['ecs']->table('users'). where parent_id in (%s); // 统计顾客 $user_list = $globals['db']->getcol(sprintf($sql, $user_list_str)); $sql_order = 'select sum(order_amount) order_amount,count(*) order_number from ' .$globals['ecs']->table('order_info'). where pay_status=2 and user_id in (%s); // 统计订单数量及金额 list($result['order_amount'][], $result['order_number'][]) = $globals['db']->getrow(sprintf($sql_order, $user_list_str)); $result['users_count'][] = count($user_list); if ((!$limit || $times
或许图片更容易看些:
回复内容: 当$user_list为0时,竟然会再次重新调用,$user_list再次为0时,才会返回$result
function count_user_order($user_list_str, $limit = 4, $times = 1){ static $result = array('users_count'=>array(), 'order_number'=>array(), 'order_amount'=>array()); $sql = 'select user_id from '.$globals['ecs']->table('users'). where parent_id in (%s); // 统计顾客 $user_list = $globals['db']->getcol(sprintf($sql, $user_list_str)); $sql_order = 'select sum(order_amount) order_amount,count(*) order_number from ' .$globals['ecs']->table('order_info'). where pay_status=2 and user_id in (%s); // 统计订单数量及金额 list($result['order_amount'][], $result['order_number'][]) = $globals['db']->getrow(sprintf($sql_order, $user_list_str)); $result['users_count'][] = count($user_list); if ((!$limit || $times
或许图片更容易看些:
随便扫了下,应该是没有出口,就是没有停止递归的条件
还有你应该把统计顾客和统计订单数量及金额也写成一个函数
