My database schema is something like this:

create table users (
  id INT PRIMARY KEY,
  username TEXT,
)

create table posts (
  id INT PRIMARY KEY,
  user_id INT,
  title TEXT,
  content TEXT,
)

Now, I want to get all posts of current logged in user, but I can't
get find a way to get current userid, like this:

$user = $this->container->get('security.context')->getToken()->getUser();
$repo->findBy(array('user_id' => $user->getId()))

But I got " Fatal Error: Call to undefined method", I wonder if there
any way to get UserId?

 I look through Symfony\Component\Security\Core\User\UserInterface,
Symfony\Component\Security\Core\User\AdvancedUserInterface, non of
them providered getId() method.

Any one can help me? Thanks.


--
Liang Zhenjing
All I wanna say is that, we do really care about you.

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