Home >Backend Development >PHP Tutorial >thinkphp data query and array traversal examples, thinkphp data query_PHP tutorial
The example in this article describes the method of data query and array traversal in thinkphp. Share it with everyone for your reference. The specific method is as follows:
The database can be configured using the DSN method:
'DB_DSN'=>'mysql://root:@localhost:3306/thinkphp',//Use DSN method to configure database information
If both methods exist at the same time, the DSN method is preferred, and there is also a simple and practical model method.
M() is equivalent to new Model();
$arr=$m->select();
You can use model instances to operate data. The operation work is generally to add, delete, modify and check the database CURD
Add -C Create $m->add()
Delete -D Delete $m->delete()
Change -U Update $m->save()
Check -R Read $m->select()
We can enable page_trace in the debugging function to help with debugging
1. Turn on the debugging function in index.php
2. You need to set the configuration file config.php (Home/Conf/) and enable page trace
Then refresh and the debugging console will appear in the lower right corner of the page, where you can view debugging information such as sql, errors, processes, files, etc.
I hope this article will be helpful to everyone’s ThinkPHP framework programming.