On 7/26/10 11:47 AM, Vincent UNG wrote:
Hi !

I'm using Symfony2 for personal project and for fun too !
Well... it's more for testing this new version.

Anyway, I was wondering, how can I execute a database query inside my
models

Actually, when I create an instance of an object, I give the $this-
container->getService('database_connection') of the controller to the
model like this :

$dbc = $this->container->getService('database_connection');
$obj = new Model($dbc);
// doing stuff with my $obj
// ...

I guess this is not the right way, but what is the right way ?
Can someone help me ?

Looks good to me.

Fabien


(My English might be quite bad, sorry for that)


--
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 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

Reply via email to