<?php
defined('PP_PATH') or exit;
class record extends model {
	function __construct() {
		$this->table = 'record';		// 表名
		$this->pri = array('id');	// 主键
		$this->maxid = 'id';		// 自增字段
	}
	
	//查找订单号
	public function getByOid($orderid){
		$data = $this->find_fetch(array('order_id'=>$orderid), array(), 0, 1);
		return $data ? array_pop($data) : array();
	}
	public function list_arr($where, $orderby, $orderway, $start, $limit, $total) {
		if($start > 1000 && $total > 2000 && $start > $total/2) {
			$orderway = -$orderway;
			$newstart = $total-$start-$limit;
			if($newstart < 0) {
				$limit += $newstart;
				$newstart = 0;
			}
			$list_arr = $this->find_fetch($where, array($orderby => $orderway), $newstart, $limit);
			return array_reverse($list_arr, TRUE);
		}else{
			return $this->find_fetch($where, array($orderby => $orderway), $start, $limit);
		}
	}
}
