php - mySQL to DQL conversion help needed -
i have next mysql query works in phpmyadmin, im running out of brain trying build doctrine equivilent querybuilder doctrine/symfony2.
select u.*, ur.*, r.* users u left bring together users_roles ur left bring together roles r on ur.roles_id = r.id on u.id = ur.users_id
please please please can help symfony2 equivilent , seek explain why solution works can seek understand better?
im finding using doctrine clear mud 1 time gets more sophisticated.
(all entities mapped , working other parts of application. can display if needed)
many thanks
** edit add together relationships **
i think im getting confused relationships. updating schema created 3rd table , think im mistakingly trying include in query.
would please help me query homecoming both user details , associated role data?
class users implements advanceduserinterface, \serializable { /*......*/ /** * @orm\manytomany(targetentity="roles", inversedby="users") * */ private $roles; /*......*/ }
and
class roles implements roleinterface { /*....*/ /** * @orm\manytomany(targetentity="users", mappedby="roles") */ private $users; /*....*/
fixed this.
after much head scratching query came works. id ignored relationships stated jiml.
$q = $this ->createquerybuilder('u') ->select('u.username, u.id userid, u.email, u.firstname, u.lastname, u.isactive, u.lastlogged, r.name, r.id') ->leftjoin('u.roles', 'r');
php mysql symfony2 doctrine2
No comments:
Post a Comment