Symfony2 joint query implementation method, symfony2 joint query
The example in this article describes the Symfony2 joint query implementation method. Share it with everyone for your reference, the details are as follows:
1.yml file
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. Query code:
$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();
I hope this article will be helpful to everyone’s PHP program design based on the Symfony framework.
Articles you may be interested in:
- Detailed explanation of page creation examples in Symfony2
- Analysis of date usage in twig of symfony2.4
- Symfony2 session and cookie Usage summary
- Summary of the method of obtaining data from the database in Symfony2
- Detailed explanation of form usage of Symfony2 framework study notes
- Plug-in format analysis of Symfony2 study notes
- Detailed explanation of system routing in Symfony2 study notes
- Detailed explanation of controller usage in Symfony2 study notes
- Detailed explanation of template usage in Symfony2 study notes
- Detailed explanation of third-party Bundles instances installed by Symfony2
- Symfony2 function usage example analysis
http://www.bkjia.com/PHPjc/1111901.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1111901.htmlTechArticleSymfony2 joint query implementation method, symfony2 joint query This article describes the Symfony2 joint query implementation method. Share it with everyone for your reference, the details are as follows: 1.yml file AcmeMs...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn