« Getting MySQL-python-1.2.2 to work on Fedora | Main | The just_sql() Function & The $reply Hash »

March 30, 2009

The $r / $_REQUEST Shortcut

Each web application built with the framework has its own paths.inc.php file for setting up common variables and paths for the application.

paths.inc.php should be the first include in any application script. One of the roles it performs is to alias the $_REQUEST global variable. A copy of this variable is created and named $r. This is for the sake of pith and saves typing as much as anything else.

$r is used quite extensively in the SQL functions. Elements in application web forms should be named the same as their corresponding DB columns. That way the $_REQUEST/$r hash can then be passed to the SQL functions to do quick and easy inserts and updates such as in the example below for adding a new user:

$userid = add_new_row('user');
        
$r['user_password'] = sha1($r['user_password']);
        
$reply = update_table('user', $r, $userid);

Tags: Lightweight OOP Framework , Lightweight PHP Web Application Framework

Posted by pj at March 30, 2009 12:17 PM

Comments