diff --git a/sys/db.php b/sys/db.php index ab849bb..00ecc4e 100644 --- a/sys/db.php +++ b/sys/db.php @@ -205,37 +205,37 @@ class db extends PDO { // -------------------------------------------------------------------------- - /** - * Returns the last error from the database - * - * @return string - */ - function get_last_error() - { - $error = array(); - - if(isset($this->statement)) - { - $error = $this->statement->errorInfo(); - } - else - { - $error = $this->errorInfo(); - } - - $code = $error[0]; - $driver_code = $error[1]; - $message = $error[2]; - - // Contain the content for buffering + /** + * Returns the last error from the database + * + * @return string + */ + function get_last_error() + { + $error = array(); + + if(isset($this->statement)) + { + $error = $this->statement->errorInfo(); + } + else + { + $error = $this->errorInfo(); + } + + $code = $error[0]; + $driver_code = $error[1]; + $message = $error[2]; + + // Contain the content for buffering ob_start(); - + include(APP_PATH.'/errors/error_db.php'); - + $buffer = ob_get_contents(); ob_end_clean(); echo $buffer; - } + } } // End of db.php \ No newline at end of file diff --git a/sys/miniMVC.php b/sys/miniMVC.php index e63edc3..2530e12 100644 --- a/sys/miniMVC.php +++ b/sys/miniMVC.php @@ -266,6 +266,21 @@ class miniMVC extends JSObject{ unset($this->$name); } } + + /** + * Convenience function to load config files + * + * @param string $name + */ + function load_config($name) + { + $path = APP_PATH . "config/{$name}.php"; + + if(is_file($path)) + { + require_once($path); + } + } } // -------------------------------------------------------------------------- diff --git a/sys/output.php b/sys/output.php index df35690..26491ec 100644 --- a/sys/output.php +++ b/sys/output.php @@ -1,20 +1,18 @@ buffer = ""; $this->headers = array(); } - // -------------------------------------------------------------------------- - /** * PHP magic method called when ending the script * Used for outputing HTML @@ -40,14 +38,11 @@ class Output extends miniMVC { if( ! empty($this->buffer)) { - ob_start("ob_gzhandler"); echo $this->buffer; ob_end_flush(); } } - // -------------------------------------------------------------------------- - /** * Sets a header for later output * @param string $key @@ -58,8 +53,6 @@ class Output extends miniMVC { $this->headers[$key] = $val; } - // -------------------------------------------------------------------------- - /** * Adds text to the output buffer * @@ -70,8 +63,6 @@ class Output extends miniMVC { $this->buffer .= $string; } - // -------------------------------------------------------------------------- - /** * Sets the output buffer * @@ -81,6 +72,28 @@ class Output extends miniMVC { { $this->buffer = $string; } + + /** + * Sends headers and then removes them + */ + function flush_headers() + { + // Set headers + foreach($this->headers as $key => $val) + { + if( ! isset($val)) + { + @header($key); + } + else + { + @header("$key: $val"); + } + } + + // Empty headers + $this->headers = array(); + } } // End of Output.php \ No newline at end of file