将值传递给Laravel数据库占位符

时间:2014-09-16 18:07:20

标签: postgresql laravel laravel-4

我如何使用Laravel的数据库表达这种语法?

SELECT ident FROM delete_team WHERE modified > to_timestamp(?)

我不确定如何传递to_timestamp占位符的值。

2 个答案:

答案 0 :(得分:1)

使用DB::select

DB::select('SELECT ident FROM delete_team WHERE modified > to_timestamp(?)', array($value));

使用查询生成器:

DB::table('delete_team')
    ->select('ident')
    ->whereRaw('modified > to_timestamp(?)', array($value)))
    ->get();

答案 1 :(得分:0)

这样的事情应该有效:

DB::select('SELECT ident FROM delete_team WHERE modified > ?', array(DB::raw("to_timestamp($value)"));