function index_get_invoice_query()
{
$sql = 'SELECT o.order_sn, o.invoice_no, s.shipping_code FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS o' .
' LEFT JOIN ' . $GLOBALS['ecs']->table('shipping') . ' AS s ON s.shipping_id = o.shipping_id' .
" WHERE invoice_no > '' AND shipping_status = " . SS_SHIPPED.
' ORDER BY shipping_time DESC LIMIT 10';
//echo $sql;
$all = $GLOBALS['db']->getAll($sql);
print_r($all); foreach ($all AS $key => $row)
{
$plugin = ROOT_PATH . 'includes/modules/shipping/' . $row['shipping_code'] . '.php'; if (file_exists($plugin))
{
include_once($plugin); $shipping = new $row['shipping_code'];
$all[$key]['invoice_no'] = $shipping->query((string)$row['invoice_no']);
}
} clearstatcache(); return $all;}打印数组为Array ( [0] => Array ( [order_sn] => 2009030695164 [invoice_no] => 2009030695164 [shipping_code] => cac ) )
{
$sql = 'SELECT o.order_sn, o.invoice_no, s.shipping_code FROM ' . $GLOBALS['ecs']->table('order_info') . ' AS o' .
' LEFT JOIN ' . $GLOBALS['ecs']->table('shipping') . ' AS s ON s.shipping_id = o.shipping_id' .
" WHERE invoice_no > '' AND shipping_status = " . SS_SHIPPED.
' ORDER BY shipping_time DESC LIMIT 10';
//echo $sql;
$all = $GLOBALS['db']->getAll($sql);
print_r($all); foreach ($all AS $key => $row)
{
$plugin = ROOT_PATH . 'includes/modules/shipping/' . $row['shipping_code'] . '.php'; if (file_exists($plugin))
{
include_once($plugin); $shipping = new $row['shipping_code'];
$all[$key]['invoice_no'] = $shipping->query((string)$row['invoice_no']);
}
} clearstatcache(); return $all;}打印数组为Array ( [0] => Array ( [order_sn] => 2009030695164 [invoice_no] => 2009030695164 [shipping_code] => cac ) )
查empty函数即可
参考文档写程序是最高效的。PHP中文版开发手册[CHM]适合PHP4/PHP5
...........
$all = $GLOBALS['db']->getAll($sql);
print_r($all);
if(!is_array($all)||count($all)==0) return array();
....
...
判断数组应该用
if(!is_array($ary) || count($ary)==0){
echo '数组为空';
exit;
}
if (sizeof($ary)>0){
echo '数组不为空';
}else{
echo '数组为空';
}