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