This article brings the content is about THINKPHP5 in the Belongstomany () module name of the naming problem resolution, there is a certain reference value, the need for friends can refer to, I hope to help you.
Recently in the development of CRM management system with TP5 a problem is that when the association query (many to many) with the BELONGSTOMANY function hint model does not exist, the following to see the specific problem.
function Introduction
My usage in the project
And look at the model layer in my TP5 again.
F_role is an association model
Ref_user_role is an intermediate table (many-to-many relationships have an intermediate table)
role_id FOREIGN Key Name
USER_ID is the primary key of F_user
This writing is entirely in accordance with the manual to write the theory that there is no problem, but the time to run to error:
Tip Fuser module does not exist, but my module name is F_user this naming method.
The reason is that there is a problem with naming rules for module names.
Solutions
Later do a short debugging to find the cause of the problem:
You need to modify the Parsemodel method in the Belongstomany method in thinkphp/think/model.php
Change 1 in the picture to 0 because
Turn the naming style into a little bit
Finally change the naming style and run the test again.
Get the data (including the associated data can be successful).