ThinkPHP returns the thinkphp array as a simple field array. ThinkPHP query returns a simple field array. thinkphp array This article describes how ThinkPHP queries and returns a simple field array, thinkPHP is a very practical method in ThinkPHP programming to query and return a simple field array, thinkphp array.
The example in this article describes how ThinkPHP returns a simple array of fields for query. 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.
If the getField of thinkphp is queried by two fields, it is not the official two-dimensional array. how can this problem be solved?
Hello ~~
$ Data = $ setting-> field ('Id, TITLE')-> select ();
ThinkPHP problems: an array (all the URLs of other websites) queried from the database, and then the HTML page
That's because you didn't write http ://
Examples in this article describes how ThinkPHP queries and returns a simple array of fields, which is a very useful feature in ThinkPHP programming...