symfony - Notice: Undefined index Repository Symfony2 -


i hope id table user using repository in action :

$user = $this->getdoctrine()->getrepository('appmybundle:user')     ->findbyusername($token['name']);   $id = $user['id'];  // $user->id or $user->getid() give me error? 

that give me error :

notice: undefined index: id in /var/www/project/src/app/mybundle/controller/defaultcontroller.php line 56  

finally var_daump output :

echo "<pre>"; var_dump($user); exit(); echo "</pre>";    array(1) { [0]=> object(app\mybundle\entity\user)#351 (21) { ["id":protected]=> int(17) .... .... 

i think want call findonebyusername method instead of findbyusername.

findby* return array of object , findoneby* return object.

after in order id call getter $id = $user->getid();

hop it's helpful.

best regard.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -