/** * 读操作,获取满足条件的数据 * @param string $sql * @param int $number * @return array $result */ public function select($sql, $number) { try { $statement = $this->_dbInstance->query($sql); if (!$statement) { throw new Exception("<br/>errorSQL:<b style='color:f00'>{$sql}</b><br/>\n"); } if (1 == $number) { $result = $statement->fetch(PDO::FETCH_ASSOC); } if ('' == $number) { $result = $statement->fetchAll(PDO::FETCH_ASSOC); } if (1 < $number) { $result = $statement->fetchAll(PDO::FETCH_ASSOC); is_array($result) && array_splice($result, $number); } return $result; } catch (PDOException $e) { exit("<br/>error<br/>" . $e->getMessage()); } return false; }