Home > Backend Development > PHP Tutorial > Symfony2 joint query implementation method, symfony2 joint query_PHP tutorial

Symfony2 joint query implementation method, symfony2 joint query_PHP tutorial

WBOY
Release: 2016-07-12 08:56:30
Original
842 people have browsed it

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
Copy after login
Acme\MspadminBundle\Entity\MspChannel:
 type: entity
 table: msp_channel
 oneToMany:
   Articles:
    targetEntity: MspArticle
    mappedBy: Channel
Copy after login
Acme\MspadminBundle\Entity\MspUser:
 type: entity
 table: msp_user
 oneToMany:
   Userone:
    targetEntity: MspArticle
    mappedBy: User

Copy after login

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();

Copy after login

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

www.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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template