Does the syntax in thinkphp define a one-to-many or one-to-one relationship?

Source: Internet
Author: User
Is there a syntax in thinkphp to define a one-to-many or one-to-one relationship? the source code below is described by a guy. the red part below is something I don't understand. please refer:
/**
* User-to-user information table association model
*/
Class UserRelationModel extends RelationModel {

// Define the name of the master table
Protected $ tableName = 'user ';

// Define the association property between the user and the user's email address table
Protected $ _ link = array (
'Userinfo' => array (
'Ing ing _ type' => HAS_ONE, // here HAS_ONE refers to a one-to-one relationship. HAS_ONE is a thinkphp syntax or custom, what is the essence of HAS_ONE here? it is said that HAS_ONE is one-to-many, which is incredible. what is the purpose of this definition?
'Forn N _ key' => 'uid' // Here is the foreign key. what is the role of this place?
)
);

/**
* Automatic insertion method
*/
Public function insert ($ data = NULL ){
$ Data = is_null ($ data )? $ _ POST: $ data;
Return $ this-> relation (true)-> data ($ data)-> add ();
}
}
?>


Reply to discussion (solution)

Haha, it's hard for you all at once, haha!

Is the associated table. One-to-multiple operations can be understood as the operations on the slave table in the master table. Multiple-to-one operations are performed on the master table from the table.
Many-to-many models of TP are not recommended and there are bugs.
We recommend that you use concatenated SQL statements to better understand the association.

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.