Welcome, Guest
Username: Password: Remember me

TOPIC: Passing a SESSION variable into a query

Passing a SESSION variable into a query 11 Apr 2016 14:05 #13907

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
This is a strange one, but I need to call a session variable in a query.. this is actually easy enough EXCEPT there is a chance that I need to regenerate that variable (using a function) before the model is called (i,e if someone visits a certain page out of order.. such as boomarked)

At what point can I call a function called (for example) getDistanceVariable and make sure it is fired BEFORE the model is rendered for the display

Does it go in the controller somewhere, in the VIEW.HTML.PHP file etc

Thanks in advance for any assistance
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The administrator has disabled public write access.

Passing a SESSION variable into a query 12 Apr 2016 07:36 #13908

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
You can fork your displayDefault function in VIEW.HTML.PHP.

The generated function starts with:
$this->model		= $model	= $this->getModel();

A couple of lines below there is
$this->items		= $items	= $this->get('Items');

Between those lines add something like (assuming getDistanceVariable returns and int)
$model->addWhere('a.distancevariable='.getDistanceVariable());
Last Edit: 12 Apr 2016 07:36 by Romkabouter.
The administrator has disabled public write access.
The following user(s) said Thank You: admin
Time to create page: 0.063 seconds

Get Started