This topic is locked

Session variable in edit sql query

4/15/2007 4:09:35 AM
PHPRunner General questions
kujox author

Can I use a session variable in the edit sql query?
I want to list a table view depending on the value of this variable if this is possible.

J
Jane 4/16/2007

Hi,
you can't use $_SESSION variable in your SQL query on the Edit SQL query tab.
I recommend you to do the following:

  • build your project
  • open generated inlude/..._variables.php file and edit query in the $gstrSQL variable.

kujox author 4/16/2007

Thanks Jane
This must be done everytime I build the project then? no other way <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=16997&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />

Sergey Kornilov admin 4/16/2007

Probably you can provide more details about what you trying to achieve and we can suggest some better workaround.

B
bed 5/10/2007

Will the ability to accept parameter input (e.g. session variable) in the "Edit SQL query" screen be in a future release of PHPRunner?

Sergey Kornilov admin 5/10/2007

We plan to introduce more events where you'll be able modify SQL query adding WHERE clause that use Session variable etc.

jwoker 11/4/2007

We plan to introduce more events where you'll be able modify SQL query adding WHERE clause that use Session variable etc.


This is what I need to do - is it possible now?
I need to filter my query to include only records with the session userid where the userid may be in one of several different fields.
Thanks

J
Jane 11/6/2007

Hi,
you can do it using List page: Before SQL query event on the Events tab.

B
benc 11/11/2007

Hi,

you can do it using List page: Before SQL query event on the Events tab.


How do I use use a session variable in the SQL query using this method, Jane?
What do I put in the 'Before SQL query' event to allow $_SESSION['UserID'] to be used in the WHERE clause of my SQL query??
Thanks in advance!
Ben

A
alang 11/11/2007

Something like:
$strSQL = AddWhere($strSQL,"`yourtablename`.`yourfieldname`='".$_SESSION['UserID']."'");