PHP Classes

$_REQUEST Variable lost

Recommend this page to a friend!

      DrasticTools  >  All threads  >  $_REQUEST Variable lost  >  (Un) Subscribe thread alerts  
Subject:$_REQUEST Variable lost
Summary:Can assign $_REQUEST variable to $options
Messages:2
Author:panac
Date:2008-11-11 11:42:41
Update:2008-11-14 22:11:57
 

  1. $_REQUEST Variable lost   Reply   Report abuse  
Picture of panac panac - 2008-11-11 11:42:42
Thanks for your time reading this post.

I am using one of the exmaples at drasticgrid, and modified to demonstrate
we can use a $_request variables as userid and handle data entry and update for that userid which are most common application.

Platform: DrasticTools version 0.6.14, PHP 5.2.6.

Steps:
1. Enter http post via browser: http://x.x.x.x/drastic2/test.php?uid=1234
2. test.php script will capture the id and process using datagrid class.
test.php is listed below.
3. Note my $options settings in the test.php:

"defaultcols" => array("uid" => $v)
{I want to force this entry using a variable captured via http post/get.
In this case uid can be used as userid for data entry or update in real life case)

"editablecols" => array("value", "beautiful", "Comment"),

{uid is not editable so not listed above, so that user can update or insert anything, and the "uid" field will be automatically update or insert with the $v variable)

4. Problem: Referring to the test.php script below, If i use $v = "1234" instead of $v = $_REQUEST['id'], everything works perfectly, but real live case $v will not be a pre-determined value.

However, if i use $v = $_REQUEST['id'] and disable $v = "1234", $v becomes empty when assigned in the $option array.

5. Without using addparam which is too complex for me, i feel the above
way, if $_REQUEST value can be properly assigned to $v, it will make the
class very easy to handle most situation for datagrid update and insert
with dynamic condition or variables and address most of the issues raised by users, who requested for conditional where clause to be added earlier
in this forum. Can we have a workaround for this ?

The example 9 at drasticgrip website is too complex for me to understand, if that's the only way to achive the above, perhaps the developer can make a simple example using addparam just for the above scenario which are pretty common use for datagrid. Drastictools is fantastic and most powerful of all i tried, it will be a pitty if this task above cannot be handled in a simplified manner.

-- test.php --

<?php
define("PATHDRASTICTOOLS", "");
include (PATHDRASTICTOOLS . "Examplemysqlconfig.php");
include (PATHDRASTICTOOLS . "drasticSrcMySQL.class.php");

$v = $_REQUEST['id'];
// $v = "1234";

$options = array(
"add_allowed" => true,
"delete_allowed" => true,
"editablecols" => array("value", "beautiful", "Comment"),
"sortcol" => "id",
"sort" => "d",
"defaultcols" => array("uid" => $v)
);

$src = new drasticSrcMySQL($server, $user, $pw, $db, $table, $options);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<link rel="stylesheet" type="text/css" href="css/grid_default.css"/>
<title>ExampleGrid8</title>
</head><body>
<script type="text/javascript" src="js/mootools-1.2-core.js"></script>
<script type="text/javascript" src="js/mootools-1.2-more.js"></script>
<script type="text/javascript" src="js/drasticGrid.js"></script>

<div id="grid1"></div>
<script type="text/javascript">
var thegrid = new drasticGrid('grid1', {pathimg:"img/", pagelength:10,
columns: [
{name: 'id', width: 40},
{name: 'uid', width: 80},
{name: 'value', width: 80},
{name: 'beautiful', width: 80},
{name: 'Comment', editable: true, width: 250}
]
});
</script>
</body></html>

  2. Re: $_REQUEST Variable lost   Reply   Report abuse  
Picture of dd dd - 2008-11-14 22:11:57 - In reply to message 1 from panac
Hi Panac,

The addparam option is explicitly designed for this. Any other way of passing parameters will not work in all cases or not work at all.
So I suggest to use the addparam option.

regards,
Drasticdata