Both the Execute () and the query () methods in thinkphp can enter SQL statements directly into the parameters. The difference is that execute () is typically used to execute SQL statements such as INSERT or update, and query is commonly used to execute statements such as SELECT. The Execute () method returns the number of records affected, and if you execute a SELECT statement for SQL, the result will be the total number of records for the table.
Here are a few specific examples to illustrate:
$model =m ("MyTable");
$result = $model->execute (' select * from MyTable '); Total row count (number) will be returned
The query () method returns the data set, which returns False if the queries are incorrect or if there are no query results
$result = $model->query (' select * from MyTable '); Will return a two-dimensional result array or false
Articles you may be interested in
- Usage and differences in PHP that jump out of multiple loops using Break,continue,goto,return,exit
- The difference and usage of return and exit, break and Contiue in PHP
- PHP empty,is_null,isset The difference between the detailed
- The usage and difference of echo,print,print_r,var_export,var_dump in PHP
- thinkphp page Jump (successerror) How to set the jump wait time
- thinkphp How to remove index.php from a URL
- Differences in PHP after adding the static keyword to variables and functions
- The last record in the thinkphp template that determines the volist loop
http://www.bkjia.com/PHPjc/764153.html www.bkjia.com true http://www.bkjia.com/PHPjc/764153.html techarticle both the Execute () and the query () methods in thinkphp can enter SQL statements directly into the parameters. The difference is that execute () is typically used to execute SQL statements such as INSERT or update, and query is commonly used to perform select and so on ...