我想知道如何连接DQL select语句中的两个字段与之间的一些文字.
我现在有这个,但没有运气......
$qb
->select('season.id, concat(competition.name, '-',season.name) AS specs')
->leftJoin('season.competition', 'competition')
->where('season.name LIKE :q')
->setParameter('q', '%'.$q.'%')
->setMaxResults($p)
;
Run Code Online (Sandbox Code Playgroud)
我们不能在这里发送三个参数,但我们可以这样做,
$em = \Zend_Registry::get('em');
$qb_1 = $em->createQueryBuilder();
$q_1 = $qb_1->select( "reprt_abs.id" )
->addSelect( "CONCAT( CONCAT(reporter.firstname, ' '), reporter.lastname)" )
->from( '\Entities\report_abuse', 'reprt_abs' )
->leftJoin( 'reprt_abs.User', 'reporter' )
->getQuery()->getResult();
Run Code Online (Sandbox Code Playgroud)
这部分就是你想要的:
$ qb_1-> select("reprt_abs.id") - > addSelect("CONCAT(CONCAT(reporter.firstname,''),reporter.lastname)")
以下是我方的输出:
array (size=19)
0 =>
array (size=2)
'id' => int 1
1 => string 'Jaskaran Singh' (length=14)
1 =>
array (size=2)
'id' => int 9
1 => string 'Harsimer Kaur' (length=14)
2 =>
array (size=2)
'id' => int 12
1 => string 'Jaskaran Singh' (length=14)
3 =>
array (size=2)
'id' => int 16
1 => string 'Jaskaran Singh' (length=14)
4 =>
array (size=2)
'id' => int 19
1 => string 'Jaskaran Singh' (length=14)
5 =>
array (size=2)
'id' => int 4
1 => string 'shilpi jaiswal' (length=14)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9495 次 |
| 最近记录: |