コード例 #1
0
 public function getList($field = '*', $where = array(), $order = array(), $limit = -1, $offset = 0)
 {
     // 校验参数
     if (!is_string($field) || empty($field)) {
         throw new LibraryException('参数错误:$field');
     }
     if (!is_array($where)) {
         throw new LibraryException('参数错误:$where');
     }
     if (!is_array($order)) {
         throw new LibraryException('参数错误:$order');
     }
     if (!is_numeric($limit) || intval($limit) != $limit) {
         throw new LibraryException('参数错误:$limit');
     }
     if (!is_numeric($offset) || intval($offset) != $offset || $offset < 0) {
         throw new LibraryException('参数错误:$offset');
     }
     // 默认id倒序
     if (empty($order) && array_key_exists('id', $this->fieldTypes)) {
         $order = array('id' => 'DESC');
     }
     // 查询
     $sql = $this->sqlBuilder->createSelectSql($field, $where, $order, $limit, $offset);
     $retList = $this->slaveHandle->queryAll($sql);
     return $retList;
 }