This article describes how ThinkPHP returns a simple array of fields for query. It is a very useful technique in the ThinkPHP query function, for more information about how ThinkPHP returns a simple array of fields, see the example in this article. It is a very useful function in ThinkPHP programming. The specific method is as follows:
Generally, select statements are used. The returned fields are arrays with complex structures. The following is a simple query:
$ Map ['parentid'] = $ id; $ sub_ids = D ('category ')-> where ($ map)-> field ("catid ") -> select ();
After the query, the result is:
[{"Catid": "23" },{ "catid": "24" },{ "catid": "25" },{ "catid ": "26" },{ "catid": "27" },{ "catid": "28" },{ "catid": "29" },{ "catid ": "30"}]
From the structure, we can see that this is a complex array with a map element.
If you only need an array that contains only the number segment elements, you can use the following method:
$ Sub_ids = D ('category ')-> where ($ map)-> getField ('catid', true );
After the query, the result is:
["23", "24", "25", "26", "27", "28", "29", "30"]
The query results are now clear and clear!
I hope this method will be helpful for ThinkPHP learning.