diff options
-rw-r--r-- | App.php | 11 | ||||
-rw-r--r-- | Controller.php | 6 | ||||
-rw-r--r-- | README | 17 |
3 files changed, 30 insertions, 4 deletions
@@ -151,8 +151,14 @@ class App */ static function error_handler($errno, $errstr, $errfile, $errline) { - $str = sprintf("%s\t%s\t%s\t%s\n", date("d.m H:i:s"), basename($errfile), $errline, $errstr); + $str = sprintf( + "%s\t%s\t%s\t%s\n", + date("d.m H:i:s"), + basename($errfile), $errline, $errstr + ); + self::log($str); + } /** @@ -257,7 +263,8 @@ class App public function js($string) { - return '<script type="text/javascript" charset="utf-8"> + header("Content-Type: text/javascript"); + print '<script type="text/javascript" charset="utf-8"> ' . $string . ' </script>'; } diff --git a/Controller.php b/Controller.php index 22dccc6..43b0efe 100644 --- a/Controller.php +++ b/Controller.php @@ -19,11 +19,14 @@ class Controller const TableName = ""; const TableSelect = ""; - function __construct() + function __construct($id = null) { // Child classes should always have the same name as their tables $this->table = strtolower(get_class($this)); $this->result = null; + if ($id) { + return $this->get($id); + } return $this; } @@ -254,6 +257,7 @@ class Controller } list($key, $value) = each($where); + $data = array(":{$key}" => $value); $sql = "DELETE FROM `{$this->table}` WHERE `{$key}` = :{$key}"; @@ -4,6 +4,7 @@ MAIN - the simple PHP framework site: public (this is the DocRoot for your site) + .htaccess (see .htaccess) index.php system (put all system support files in here) lib @@ -25,7 +26,7 @@ A typical index.php using MAIN would look like this: . "{$sysdir}/lib" . PATH_SEPARATOR . "{$sysdir}/conf" . PATH_SEPARATOR . "{$sysdir}/classes" . PATH_SEPARATOR - ); + ); require_once "main/app.php"; require_once "main/controller.php"; @@ -35,3 +36,17 @@ A typical index.php using MAIN would look like this: App::init(); ?> + +## .htaccess ## + +Main uses and is developed on using Apache httpd's mod_rewrite module. The .htaccess file in your web app's +public root folder should look something like this: + +<IfModule mod_rewrite.c> + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} -s [OR] + RewriteCond %{REQUEST_FILENAME} -l [OR] + RewriteCond %{REQUEST_FILENAME} -d + RewriteRule ^.*$ - [NC,L] + RewriteRule ^.*$ index.php [NC,L] +</IfModule> |