About tp6.0 native sql query operation

V6.0.3+queryStarting 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.

queryThe method is used to execute SQLthe 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

executeThe 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

Guess you like

Origin blog.csdn.net/qq_58778333/article/details/130152007
Recommended