V6.0.3+
query
Starting from the version, native query only supports Db class operations, and does not support calling native query methods (including and methods) in the model execute
.
query
The method is used to execute SQL
the query operation and return the query result data set (array).
Execution: Db::query("select * from edu_wx_classes_stu where id=? AND stu_id=?", [178, 127]);//Parameter binding
The corresponding sql statement is
select * from edu_wx_classes_stu where id=178 AND stu_id=127
execute
The sql operation used to update and write data, if the data is illegal or the query is wrong, it will return false
, otherwise it will return the number of affected records.
implement:
Db::execute("update edu_wx_classes_stu set remark=:name where id=:status", ['name' => 'thinkphp', 'status' => 178]); //命名绑定
The corresponding sql statement is
update edu_wx_classes_stu set remark='thinkphp' where id=178