/** * 执行具体SQL操作 * 返回:运行结果 * 类型:数组 */ public function query($sql, $type = '1') { $result = array(); self::$stmt = self::$DB->query($sql); self::getPDOError($sql); self::$stmt->setFetchMode(PDO::FETCH_ASSOC); switch ($type) { case '0': $result = self::$stmt->fetch(); break; case '1': $result = self::$stmt->fetchAll(); break; case '2': $result = self::$stmt->rowCount(); break; } self::$stmt = null; return $result; }