I want to get from the database $idand $name, but I get this exception:
No id for request Grupa \ ProjektBundle \ Entity \ Car
I have GeneratedValue(strategy="AUTO")in the annotations of Doctrine in essence Car. How can i fix this? Routing is consistent!
In addition, I have a database record with identifier 1 and a name with the value of some URL pointing to the image ( http://www.supercarworld.com/images/fullpics/595.jpg ).
This is my controller called SupercarsController.php :
namespace Grupa\ProjektBundle\Controller;
use Grupa\ProjektBundle\Entity\Car;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class SupercarsController extends Controller
{
public function scAction($id = null, $name = null){
$car = new Car();
$car = $this->getDoctrine()
->getRepository('GrupaProjektBundle:Car')
->find($id, $name);
return $this->render('GrupaProjektBundle:Sc:supercars.html.twig');
}
public function showAction($slug)
{
$url = $this->generateUrl('grupa_projekt_supercars',
array('slug' => 'marka')
);
return $this->render('GrupaProjektBundle:Sc:makes.html.twig');
}
}
This is my essence Car.php :
namespace Grupa\ProjektBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
class Car
{
protected $id;
protected $name;
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
return $id;
}
public function setName($name)
{
$this->name = $name;
return $this;
}
public function getName()
{
return $this->name;
}
}