《PHP教程:Symfony2聯(lián)合查詢實(shí)現(xiàn)方法》要點(diǎn):
本文介紹了PHP教程:Symfony2聯(lián)合查詢實(shí)現(xiàn)方法,希望對(duì)您有用。如果有疑問(wèn),可以聯(lián)系我們。
本文實(shí)例講述了Symfony2聯(lián)合查詢實(shí)現(xiàn)辦法.分享給大家供大家參考,具體如下:PHP應(yīng)用
1.yml文件PHP應(yīng)用
Acme\MspadminBundle\Entity\MspArticle: type: entity table: msp_article manyToOne: Channel: targetEntity: MspChannel inversedBy: Articles joinColumn: name: channel_id referencedColumnName: channel_id User: targetEntity: MspUser inversedBy: Userone joinColumn: name: user_id referencedColumnName: user_id
Acme\MspadminBundle\Entity\MspChannel: type: entity table: msp_channel oneToMany: Articles: targetEntity: MspArticle mappedBy: Channel
Acme\MspadminBundle\Entity\MspUser: type: entity table: msp_user oneToMany: Userone: targetEntity: MspArticle mappedBy: User
2.查詢代碼:PHP應(yīng)用
$sql="SELECT a.id,a.checkStatus,a.title,a.releaseSysDate, a.visitTotal,u.userName ,n.name FROM AcmeMspadminBundle:MspArticle a JOIN a.User u JOIN a.Channel n"; $query = $emt->createQuery($sql." Where a.checkStatus = 0 "); $mspArtile = $query->getResult();
希望本文所述對(duì)大家基于Symfony框架的PHP程序設(shè)計(jì)有所贊助.PHP應(yīng)用
《PHP教程:Symfony2聯(lián)合查詢實(shí)現(xiàn)方法》是否對(duì)您有啟發(fā),歡迎查看更多與《PHP教程:Symfony2聯(lián)合查詢實(shí)現(xiàn)方法》相關(guān)教程,學(xué)精學(xué)透。維易PHP學(xué)院為您提供精彩教程。
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.snjht.com/jiaocheng/7307.html