开发者

Can someone explain why the following DQL works?

开发者 https://www.devze.com 2022-12-20 16:33 出处:网络
$user = Doctrine_Core::getTable开发者_如何学运维(\'User\') ->createQuery(\'u\') ->innerJoin(\'u.Profile p\')
$user = Doctrine_Core::getTable开发者_如何学运维('User')
    ->createQuery('u')
    ->innerJoin('u.Profile p')
    ->where('p.username = ?', 'jwage')
    ->fetchOne();

It looks quite different from SQL which I'm quite used to,especially what does the u mean?

Can someone make it clear by a decent explanation?


$q = Doctrine::getTable('User')->createQuery('u')->where('u.username = ?', 'JRL');

is a shorthand method for this:

$q = Doctrine_Query::create()->from('User u')->where('u.username = ?', 'JRL');

The createQuery method is declared as such: createQuery($alias = '')


Seems to me like the u means the User table. It's just a short alias for it.

0

精彩评论

暂无评论...
验证码 换一张
取 消