public static function query($query) { echo "<p>{$query}</p>"; if (is_null(self::$dbConnection)) { self::$object = new self(); } try { $results = mysql_query($query); if (mysql_error(self::$dbConnection)) { $error = mysql_error(self::$dbConnection); $errorNum = mysql_errno(self::$dbConnection); throw new Exception("Unable to execute query: {$query}." . " Error text: {$error}." . " Error details: {$errorNum}"); } } catch (Exception $e) { echo '<p> Exception was thrown: ', $e->getMessage(), '</p>'; } $items = array(); while ($row = mysql_fetch_assoc($results)) { $items[] = $row; } return $items; }