在Laravel 4中,我能够使用...获取当前路线名称
Route::currentRouteName()
Run Code Online (Sandbox Code Playgroud)
我怎么能在Laravel 5中做到这一点?
我试图使用postgresql从表(login_history为t1)中检索分钟的时差.
当我尝试这个代码
((date_part('hour', timestamp '2014-04-25 09:44:21')- date_part('hour', timestamp '2014-04-25 08:32:21'))*60 +(date_part('minutes', timestamp '2014-04-25 09:44:21')- date_part('minutes', timestamp '2014-04-25 08:32:21'))) as TimeNew
Run Code Online (Sandbox Code Playgroud)
它工作正常.但是当我尝试使用此代码从表t1中检索信息时
((date_part('hour', timestamp t1.login_date)- date_part('hour', timestamp t1.logout_date))*60 +
(date_part('minutes', timestamp t1.login_date)- date_part('minutes', timestamp t1.logout_date))
) as TimeNew
Run Code Online (Sandbox Code Playgroud)
它抛出了这个错误
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "t1"
Run Code Online (Sandbox Code Playgroud)
谢谢
我正在尝试替换mysql 中某个字段中所有出现的特定文本。
我在代码字段中有以下数据。
代码
你好12
12你好
12hel12
1212hi1
我想要以下输出
你好
地狱12
12嗨1
我尝试过以下代码
UPDATE code_table
SET code = REPLACE(code, '12', '')
Run Code Online (Sandbox Code Playgroud)
输出
你好
你好
赫尔
你好1
我也尝试过这段代码
UPDATE code_table
SET code = REPLACE(code, '12', '')
where code regexp ('^12')
Run Code Online (Sandbox Code Playgroud)
但我得到以下输出
你好
赫尔
你好1
这是预期的,因为 where 子句仅检查数据在字符串开头是否有12 ,并替换字符串中所有出现的 12 。
有没有办法在替换中使用正则表达式?
我正在尝试为我的应用程序设置全局变量.
我看到了一些建议和自定义配置文件就是其中之一.
所以我constraints.php
在config目录下创建了一个文件.
这是示例代码:
return [
'user_exist'=>1
];
Run Code Online (Sandbox Code Playgroud)
我可以使用config('constraints.user_exist')访问此值
所以我尝试了以下代码:
return [
'user_exist'=>count(\App\User::first())
];
Run Code Online (Sandbox Code Playgroud)
但它抛出以下错误: PHP致命错误: 在3308行上的project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php中调用null上的成员函数connection()