The difference between execute and query methods in ThinkPHP. In ThinkPHP, the execute () and query () methods can both directly input SQL statements in parameters. The difference is that execute () is usually used to execute SQL statements such as insert or update, while query is often used to execute () and query () in ThinkPHP such as select () you can directly enter SQL statements in parameters. The difference is that execute () is usually used to execute SQL statements such as insert or update, while query is often used to execute select statements. The execute () method returns the number of affected records. if you execute the select statement of SQL, the returned results will be the total number of records of the table.
The following are examples:
$ Model = M ("MyTable ");
$ Result = $ model-> execute ('select * from mytable'); // The total number of returned rows (number)
The query () method returns the dataset. if the query statement is incorrect or there is no query result, false is returned.
$ Result = $ model-> query ('select * from mytable'); // A two-dimensional result array or false is returned.
Articles you may be interested in
- Use break, continue, goto, return, and exit in multiple loops in PHP
- Differences and usage of return, exit, break, and contiue in PHP
- Empty, is_null, and isset in php
- Differences between echo, print, print_r, var_export, and var_dump in php
- How to set the jump wait time for the thinkphp page jump (successerror)
- How does thinkphp remove index. php from the url?
- Differences between variables and functions in php after the static keyword is added
- The last record of the volist loop in the thinkphp Template
The explain () and query () methods can both directly input SQL statements in parameters. The difference is that execute () is usually used to execute SQL statements such as insert or update, while query is often used to execute select...