use*_*667 4 php orm laravel eloquent
我遇到过这个
$user = User::whereConfirmationCode($confirmation_code)->first();
Run Code Online (Sandbox Code Playgroud)
在Laravels雄辩的ORM中,你可以在上面的where语句中附加表格行名称吗?
在我看到这之前我会写的
例如: $user = User::where('confirmation_code', '=', $confirmation_code)->first();
谢谢
xAo*_*Aoc 12
'是的,你可以在哪里建立动态.它在简单的where语句中进行解析.你也可以像这样构建魔术查询:
$user = User::whereConfirmationCodeAndIdOrRole(12345, 5, 'admin')->first();
Run Code Online (Sandbox Code Playgroud)
它将转变为:
$user = User::where('confirmation_code', '=', 123456, 'and')->where('id', '=', 5, 'or')->where('role', '=', 'admin')->first();
Run Code Online (Sandbox Code Playgroud)