From dead03e955367d4635764251f62256365c01b221 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Tue, 20 Jul 2010 07:22:23 +0300 Subject: ordering children, PHP 5.3 changes --- MainApp.php | 54 +++++++++++++----------------------------------------- 1 file changed, 13 insertions(+), 41 deletions(-) (limited to 'MainApp.php') diff --git a/MainApp.php b/MainApp.php index 5a149a8..3ad37a0 100644 --- a/MainApp.php +++ b/MainApp.php @@ -10,7 +10,6 @@ class MainApp static public function init() { $url = self::url(); - @list($controller, $param, $action) = $url; // no controller given, read default one @@ -193,45 +192,6 @@ class MainApp return sprintf('%s_%s', $loc, strtoupper($lang)); } - public function delete($table, $where) - { - if (empty($where)) { - exit(self::error('Delete without parameters')); - } - - list($key, $value) = each($where); - $sql = "DELETE FROM `$table` WHERE $key = :{$key}"; - - self::log($sql); - self::query($sql, $where); - - } - - //// - // insert something in the database - static function insert($table, $data) - { - if (empty($data)) { - exit(self::error('Empty insert')); - } - - $cols = array(); - $vals = array(); - - foreach ($data as $k => $v) { - $cols[] = "`{$k}`"; - $vals[] = ":{$k}"; - } - - $cols = implode(',', $cols); - $vals = implode(',', $vals); - $sql = "INSERT INTO `$table` ($cols) VALUES ($vals)"; - - self::log($sql); - self::query($sql, $data); - - } - // Move this back to Controller once PHP 5.3 is out (get_called_class()) static function select($table, $where = 1, $what = '*', $order_by = '') { @@ -292,13 +252,25 @@ class MainApp //// // output a JavaScript fragment - public function js($string) + static function js($string) { header('Content-Type: text/javascript'); header('Content-Length: '.strlen($string)); echo ''; } + //// + // urlencode() string twice to work with mod_rewrite + static function urlenc($string) + { + return urlencode(urlencode($string)); + } + + static function urldec($string) + { + return urldecode(urldecode($string)); + } + } //// -- cgit v1.2.3