OK but the campaign_id is likely to change from one HTTP request to another so I only want to store the campaign_id during ONE HTTP request (so I don't have to retrive this ID for each product because that mean 20 same SQL request if their is 20 product on the page .... ) Am I clear enough ?
Thanks for your help :) 2009/2/9 Sid Bachtiar <sid.bacht...@gmail.com> > > Not flash! Use your user object, e.g.: > > public function executeMyAction() > { > $user = $this->getUser(); > $user->setAttribute('campaign_id', 3); > } > > Then later use $user->getAttribute('campaign_id') from anywhere in > your project to retrieve it. > > On Tue, Feb 10, 2009 at 3:52 AM, Olivier Revollat <revol...@gmail.com> > wrote: > > All right, or maybe I can use session (flash) ... ? > > > > 2009/2/9 Iltar <kja...@gmail.com> > >> > >> Hey, > >> If I understand you correctly, you want to have the id like "3" > >> available in every part of your script? > >> > >> Try setting it as a config value: sfConfig::set('campaign_id', > >> $campaign->getId()); if I recall correctly. This is available > >> everywhere. Else I recommend either bridging to Zend Framework for a > >> registry, or build on yourself. > >> > >> On Feb 9, 11:52 am, Olivier Revollat <revol...@gmail.com> wrote: > >> > Hello ! > >> > On my application (e-commerce) I list the available products. For each > >> > products I call a filter that modify the product price according to > >> > current > >> > price campaign (if any campaign is active) > >> > So for each products, I retrive the current campagne (SQL QUERY) : > >> > > >> > $query = sprintf("SELECT %s AS campagneid FROM %s WHERE NOW() BETWEEN > %s > >> > AND > >> > %s LIMIT 1", AmaCampagnePeer::ID, AmaCampagnePeer::TABLE_NAME, > >> > AmaCampagnePeer::DEBUT_VALIDITE, AmaCampagnePeer::FIN_VALIDITE); > >> > $statement = $connection->prepare($query); > >> > $statement->execute(); > >> > $campagneid = $statement->fetch(PDO::FETCH_OBJ); > >> > > >> > But as soon as I get the current's campagn ID this is not going to > >> > change > >> > during the current HTTP request ... so I don't have to execute this > >> > request > >> > for each products... I want to use the same campagne ID for all the > HTTP > >> > request and not recalculate it each time I filter a product (to > retrive > >> > the > >> > campagne price) ... some kind of singleton design pattern .. but I > don't > >> > know exactly how to implement this (for example how do I know that I > am > >> > I > >> > the same HTTP request ?) > >> > I don't know if i'm clear enougth ... :) > >> > > >> > Thanks for your help, ideas, suggestions !! > >> > > > > > > > > > > > > > -- > Blue Horn Ltd - System Development > http://bluehorn.co.nz > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---