Symfony2聯(lián)合查詢實(shí)現(xiàn)方法
更新時(shí)間:2016年03月18日 11:56:17 作者:ypb455360299
這篇文章主要介紹了Symfony2聯(lián)合查詢實(shí)現(xiàn)方法,結(jié)合實(shí)例形式簡(jiǎn)單分析了Symfony2聯(lián)合查詢的具體步驟與實(shí)現(xiàn)技巧,需要的朋友可以參考下
本文實(shí)例講述了Symfony2聯(lián)合查詢實(shí)現(xiàn)方法。分享給大家供大家參考,具體如下:
1.yml文件
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.查詢代碼:
$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ì)有所幫助。
您可能感興趣的文章:
- Symfony查詢方法實(shí)例小結(jié)
- Symfony2使用Doctrine進(jìn)行數(shù)據(jù)庫查詢方法實(shí)例總結(jié)
- 高性能PHP框架Symfony2經(jīng)典入門教程
- Symfony2實(shí)現(xiàn)從數(shù)據(jù)庫獲取數(shù)據(jù)的方法小結(jié)
- Symfony2學(xué)習(xí)筆記之模板用法詳解
- Symfony2框架學(xué)習(xí)筆記之表單用法詳解
- Symfony2框架創(chuàng)建項(xiàng)目與模板設(shè)置實(shí)例詳解
- symfony2.4的twig中date用法分析
- Symfony2學(xué)習(xí)筆記之控制器用法詳解
- Symfony2安裝第三方Bundles實(shí)例詳解
- Symfony2實(shí)現(xiàn)在controller中獲取url的方法
- Symfony2針對(duì)輸入時(shí)間進(jìn)行查詢的方法分析
相關(guān)文章
php使用shmop函數(shù)創(chuàng)建共享內(nèi)存減少負(fù)載的方法
這篇文章主要介紹了php使用shmop函數(shù)創(chuàng)建共享內(nèi)存減少負(fù)載,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-12-12
ThinkPHP3.1.x修改成功與失敗跳轉(zhuǎn)頁面的方法
這篇文章主要介紹了ThinkPHP3.1.x修改成功與失敗跳轉(zhuǎn)頁面的方法,涉及thinkPHP底層源文件中相關(guān)跳轉(zhuǎn)代碼的設(shè)置與修改操作技巧,需要的朋友可以參考下2017-09-09
laravel 解決paginate查詢多個(gè)字段報(bào)錯(cuò)的問題
今天小編就為大家分享一篇laravel 解決paginate查詢多個(gè)字段報(bào)錯(cuò)的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-10-10
Yii2使用dropdownlist實(shí)現(xiàn)地區(qū)三級(jí)聯(lián)動(dòng)功能的方法
這篇文章主要介紹了Yii2使用dropdownlist實(shí)現(xiàn)地區(qū)三級(jí)聯(lián)動(dòng)功能的方法,結(jié)合實(shí)例形式較為詳細(xì)的分析了dropdownlist下拉列表實(shí)現(xiàn)三級(jí)聯(lián)動(dòng)調(diào)用的具體步驟與相關(guān)注意事項(xiàng),需要的朋友可以參考下2016-07-07
MacOS下PHP7.1升級(jí)到PHP7.4.15的方法
這篇文章主要介紹了MacOS下PHP7.1升級(jí)到PHP7.4.15的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-02-02

