Symfony2 joint query implementation method _ php instance

Source: Internet
Author: User
This article mainly introduces the implementation of Symfony2 joint query, and analyzes the specific steps and implementation skills of Symfony2 joint query in combination with the instance form, for more information about how to implement the Symfony2 joint query, see the example in this article. We will share this with you 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.checkStatus,a.title,a.releaseSysDate,          a.visitTotal,u.userName , 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 help you design PHP programs based on the Symfony framework.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.