What should be the best practice to insert a foreign key in an object in symfony2, if i already have the id of the foreign key?
If i have an action:
/**
* @Route("assignCategory/{category}/product/{product}")
*/
public function assignCategory($category, $product)
{
...
// here i should set the category to the existing product
...
}
I don't like the idea of retrieving the category from the database.
This also applies if you have ids in session and you want to store them to the object but without retrieving it from the database... so... what should be the best practice for this?