Home > Backend Development > PHP Tutorial > Association Model and Infinitus Classification_PHP Tutorial

Association Model and Infinitus Classification_PHP Tutorial

WBOY
Release: 2016-07-14 10:10:36
Original
898 people have browsed it

Today’s summary:
Association Model
ONE_TO_ONE : HAS_ONE&BELONGS_TO
ONE_TO_MANY : HAS_MANY&BELONGS_TO
MANY_TO_MANY


First, define the model class headed by the table name on the model side. Integrate the associated model class
Define protected variables in the class $_link = array(); which is the mapping method of the fields;
For example: the user table is mapped to archive to hasone mapping method, or one-to-one can also use belongsto
dept is belongsto mapping method
grp is manytomany mapping method
The default manytomany mode intermediate table name should be defined as operation indication_target table name
You can also set the value of relationship_table for initialization
hasone instantiates the object, sets the relation() parameter to a true value, and calls the object relational mapping method to add, delete, modify and check


After the associated model object is added, deleted, modified and checked, the only corresponding field associated with it will be changed


Autofill~Complete unlimited classification


Instantiate the object in the active segment. Call the field method. The parameters include the concat method parameter, which contains the path connector - id as bpath, and call the order method parameter of the coherent operation as bpath, and the select method of the object-relational mapping. foreache traverses the multiple pieces of data obtained above and adds a new field count to each piece. The count method parameter is the explode method parameter is the connector - the bpath field, so that each record adds a count field equal to its own path length. Let Then call the assign method under ¥this to assign the value and call the display method to display.
On the view side, the form submission direction is add activity. Call the volist tag so that the value of the option tag is {$vo['id']}. Use the php tag within the volist tag to perform a for loop and output spaces. Output the name value outside the php tag
Set the automatically completed value on the custom model side to array. Set the path field to the callback function tclm to fill in the column. Define the function tclm. Set the pid to the passed pid. If not, assign it to 0. If it is 0, return 0. The query id is The entry setting of pid returns the data as the path connection of the parent item - just connect the id of the parent item

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477486.htmlTechArticleToday’s summary: Association model ONE_TO_ONE : HAS_ONEBELONGS_TO ONE_TO_MANY : HAS_MANYBELONGS_TO MANY_TO_MANY First define the model class integration headed by the table name on the model side The associated model class is in...
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