更新时间:2022-05-02 22:47:02
您可以使用此功能:
int affectingStatement (字符串$ query,数组$ bindings = array())
int affectingStatement(string $query, array $bindings = array())
运行一条SQL语句并获取受影响的行数.
Run an SQL statement and get the number of rows affected.
参数
返回值
This function is already documented for laravel 4.2 as well as for 5.4.
请注意,insert()
是statement()
的别名,并且将返回布尔值.而功能update()
和delete()
是affectingStatement()
的别名.因此,如果您想变得有趣并引起审阅者的困惑,您也可以写$rowCount = DB::delete("INSERT IGNORE ...", $bindings)
-它会起作用.
Note that insert()
is an alias for statement()
and will return a boolean. While the functions update()
and delete()
are aliases for affectingStatement()
. So if you want to be funny and confuse the reviewers you could also write $rowCount = DB::delete("INSERT IGNORE ...", $bindings)
- and it will work.