|
|
PathDatabaseInteraction
When you create GET and POST functions you can pass 2 paramaters, the $path and the $db.
$path
This is where all the path variables are stored for URL handling. Print it print_r($path); and you'll see. So if you have something like http://localhost/index.php/view/2 you probably want to retrieve the number 2, you can simply do $path->pathVars[1].
$db
Here is where the database stuff goes on. Before we use this we need to pass an Array for database connection to our wephp initializer:
$db_parameters = array(
'user'=> 'root',
'pw' => '',
'db' => 'database'
);And add it to our initializer at the last line:
web::run($urls, $db_parameters);
Now we can start playing with our $db object, for example:
$query = $db->query('SELECT * FROM table');
$data['table'] = $query->fetchall();
Sign in to add a comment
