Hi Jeremy, what stops you from constructing the Entity with $agency_id?
Normally you would only need to define its __construct method public function __construct($agency_id) { $this->agency_id = $agency_id; } A better way imo would be to create a RouteManager service with a factory method createRoute(), something like: public function createRoute() { return new Route($this->getCurrentAgency()); // current agency could be a service or you could get it from the logged in User entity relation Agency if such exists } // You would need to change the Route constructor to accept Agency Entity There are tons of different ways to achieve this each with its pros and cons. If you share more details of your issue im sure you will get better (and more) answers. I hope that helps. Cheers On Fri, Feb 10, 2012 at 7:03 AM, Jeremy Krygsman <jkrygs...@adigitalcity.com > wrote: > Hi everyone, > > This is my first post on the group! I'm just getting started in > Symfony 2, and I'm really pleased so far, so thanks to everyone who is > involved in creating it. > > I have a small challenge related to database interaction using > Doctrine. I have an application that currently uses many identical > sets of tables pertaining to multiple different transit agencies. Each > agency has similar information within the tables (for example, a > 'routes' table and a 'stops' table), but I would like to keep each > agency's tables separate for data manageability reasons. The way I > would previously interact with the different tables in sql is by > adding an 'agency_id' prefix to the SELECT FROM query. For example: > > 'SELECT * FROM' . $agency_id . '_routes' > > In this way, I'm able to easily access any agency's 'routes' table > without writing a unique query for each agency. With Doctrine, though, > the entities must be pre-defined in the Entity folder within php > classes, and you call these entities in the code with: > > $route = new Route(); > > This doesn't seem to leave a lot of flexibility to use the same entity > declarations to access multiple, similar tables. Any ideas on how to > acheive that kind of flexibility? If I could just do something like: > > $route = new Route($agency_id); > > that would be great. But any suggestions would be greatly appreciated. > > -- > If you want to report a vulnerability issue on symfony, please send it to > security at symfony-project.com > > You received this message because you are subscribed to the Google > Groups "symfony developers" group. > To post to this group, send email to symfony-devs@googlegroups.com > To unsubscribe from this group, send email to > symfony-devs+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/symfony-devs?hl=en > -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to symfony-devs@googlegroups.com To unsubscribe from this group, send email to symfony-devs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en