This article mainly introduces about TP5 how to display different fields on the interface, has a certain reference value, now share to everyone, the need for friends can refer to
Environmental ThinkPHP5 PHP7.0.10
We usually hide some fields and apply them to different interfaces.
Change the database's configuration file first, changing the data set return type to collection
The query for our interface below is handled either by find () or select ()
$Group = $Group->hidden ([' name ']);
$Group is the data that mode queries, and this line of code means to hide the name.
Of course we can also use the visible () method to define what fields are displayed, so that in the model I can add some fields that do not need to be displayed in the $hidden array, and the selection of the other fields in the controller
Let's look at an example
This is all the information read
Below we hide the name field
Or just display the name
In this way, we can flexibly define the interface display information to the client, in the model can also not choose to hide, the client's information display is selected in the controller
Suppose I hide this field in the model, and then select Show only This field in the controller, he will also be displayed on the client side.
You can see that the model is hidden and can be changed by the controller.
Related recommendations:
PHP5 Connecting an image field in a mssql2005 database table display