Bonjour,

Je veux effectuer une requête udpate sur mon entité profile. Cette requête récupère les données à partir d'un formulaire, nommé formulaire1. Au niveau du repository j'ai développé la requête update suivante:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
 
namespace Zero\UserBundle\Entity;
 
use Doctrine\ORM\EntityRepository;
 
 
class ProfileRepository extends EntityRepository
{
 
 
	public function update_formulaire1($user,$first_name, $last_name, $dateofbirth, $town)
	{
 
		$qb = $this->_em->createQueryBuilder('p');
 
		$q = $qb->update('ZeroUserBundle:Profile', 'p')
		        -> set ('p.first_name',$first_name)
				-> set ('p.last_name', $last_name)
				-> set ('p.date_of_birth', $dateofbirth)
				-> set ('p.town', $town)
                ->where('p.email = :email')
                ->setParameter('email', $user)
				->getQuery()->execute();
 
	}
 
 
 
}
Et au niveau du contrôleur, j'ai le code suivant:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 
 
	public function formulaire1Action($user)
    {
 
 
		$profile = new profile();
 
 
		$form = $this->createForm(new ProfileType, $profile);
 
		$request = $this->get('request');
 
		if( $request->getMethod() == 'POST' )
        {
 
			 $profile_repository = $this->getDoctrine()->getEntityManager()->getRepository('ZeroUserBundle:Profile');
			 $profile_repository->update_formulaire1($user, $form->getData('firstName'), $form->getData('lastName'), $form->getData('dateOfBirth'), $form->getData('town'));
 
             return $this->redirect( $this->generateUrl('zeroprofil_formulaire2'));		 			
		}
 
 
        return $this->render('ZeroProfilBundle:Profile:formulaire1.html.twig',array('form' => $form->createView(),));
    }
En exécutant cet algorithme je reçois l'erreur suivante:

[Syntax Error] line 0, col 52: Error: Expected Literal, got 'WHERE'

[2/2] QueryException: [Syntax Error] line 0, col 52: Error: Expected Literal, got 'WHERE'

[1/2] QueryException: UPDATE ZeroUserBundle:Profile p SET p.first_name = WHERE p.email = :email
Une idée svp? je galère depuis hier sans aucune solution