一句代码问两问题?

2016-07-07 15:02 来源:www.chinab4c.com 作者:ecshop专家

"AND a.start_time <= '$now' AND a.end_time >= '$now' AND a.is_finished < 2 ORDER BY a.act_id DESC";

问题1:这句话怎么添加个功能a.end_time - $now <=30分钟这代码要怎么写?

问题2:a.act_id DESC想改成按一口价从低到高排序,加入a.end_price DESC 居然报错,这怎么搞?

这是有关auction.php的问题

/**
* 取得某页的拍卖活动
* @paramint$size每页记录数
* @paramint$page当前页
* @returnarray
*/
function auction_list($size, $page)
{
$auction_list = array();
$auction_list['finished'] = $auction_list['finished'] = array();

$now = gmtime();
$sql = "SELECT a.*, IFNULL(g.goods_thumb, '') AS goods_thumb " .
"FROM " . $GLOBALS['ecs']->table('goods_activity') . " AS a " .
"LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON a.goods_id = g.goods_id " .
"WHERE a.act_type = '" . GAT_AUCTION . "' " .
"AND a.start_time <= '$now' AND a.end_time >= '$now' AND a.is_finished < 2 ORDER BY a.act_id DESC";
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
while ($row = $GLOBALS['db']->fetchRow($res))
{
$ext_info = unserialize($row['ext_info']);
$auction = array_merge($row, $ext_info);
$auction['status_no'] = auction_status($auction);

$auction['start_time'] = local_date($GLOBALS['_CFG']['time_format'], $auction['start_time']);
$auction['end_time']= local_date($GLOBALS['_CFG']['time_format'], $auction['end_time']);
$auction['formated_start_price'] = price_format($auction['start_price']);
$auction['formated_end_price'] = price_format($auction['end_price']);
$auction['formated_deposit'] = price_format($auction['deposit']);
$auction['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$auction['url'] = build_uri('auction', array('auid'=>$auction['act_id']));

if($auction['status_no'] < 2)
{
$auction_list['under_way'][] = $auction;
}
else
{
$auction_list['finished'][] = $auction;
}
}

$auction_list = @array_merge($auction_list['under_way'], $auction_list['finished']);

return $auction_list;
}