thinkphp-Correlation model

Source: Internet
Author: User

Before using, the folder should be introduced, otherwise the corresponding function will not be implemented.

If you are not proficient in thinkphp, use or development, it is best to use the completed version of thinkphp directly.

Relational model definitions:

<?PHP/** * Inherit from Relationmodel, be sure to include the Model file in the extension * thinkphp\extend\model\relationmodel.class.php*/classMessagemodel extends relationmodel{//Mapping Relationships    protected$_link =Array (//a user can have more than one message, a message belongs to only one user        'User'=Array (//Association Type            'Mapping_type'=belongs_to,//corresponding FOREIGN key            'Foreign_key'='UID',            //Map Name            'Mapping_name'='User',            //map fields, do not write this property, default to all fields            'Mapping_fields'='username',            //is directly written to the results of the query and is not displayed in a two-dimensional array.             'As_fields'='username',        ),    ); }

Usage Rules:

 Public function Left () {    = D ('Message');     = $msg->relation (true),select();            $this->assign ('data', $res);    $This, display ();

thinkphp-Correlation model

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: info-contact@alibabacloud.com 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.