Php 获取PostgreSQL';是拉威尔的nextval()吗?

Php 获取PostgreSQL';是拉威尔的nextval()吗?,php,postgresql,laravel,Php,Postgresql,Laravel,我正在创建一个crud,它利用了Laravel中的wizard。我想知道如何获取某个表的nextval(),以便将其存储为会话 目前,我在控制器上这样做: public function index() { // get all the reports $reports = Reports::all(); $query = "select nextval('app_reports_mgmt.reports_rid_seq')"; $next_rid = R

我正在创建一个crud,它利用了Laravel中的wizard。我想知道如何获取某个表的nextval(),以便将其存储为会话

目前,我在控制器上这样做:

    public function index()
{
    // get all the reports
    $reports = Reports::all();
    $query = "select nextval('app_reports_mgmt.reports_rid_seq')";
    $next_rid = Reports::raw($query)->get();
    Session::put('next_rid', $next_rid);

    // load the view and pass the reports
    return View::make('templates.reports')
        ->with('reports', $reports);
}
但每次我打印next_rid时,它实际上都会将所有数据存储在表中。 这是一个很长的结果,但下面是输出的一个片段:

[{“rid”:4,“name”:“Test validation table Test”,“encryption”:“Test”,“internal\u external”:“external”,“client”:“Account 1”,“isdateadded”:“No”,“savewithmacro”:“xlsx”,“deleteconnections”:“True”,“nameofemailbodysheet”:“1”,“validationtables”:“5”,“validationchecks”:“customemailtext”:“3”,“报告状态”:“WIP”,“自定义电子邮件主题”:“2”,“报告pc”:“ccrep-eu-rbox02”、“pc用户”:“报告欧盟”、“自定义附件名称”

我浏览了laracasts和其他几个网站,但似乎没有任何Laravel函数可以获取下一张表。 提前感谢。

您可以使用
value()
函数

public function index()
{
    // get all the reports
    $reports = Reports::all();
    $query = "nextval('app_reports_mgmt.reports_rid_seq') as nxt";
    $next_rid = Reports::selectRaw($query)->value('nxt');
    Session::put('next_rid', $next_rid);

    // load the view and pass the reports
    return View::make('templates.reports')
        ->with('reports', $reports);
}
您可以使用
value()
函数

public function index()
{
    // get all the reports
    $reports = Reports::all();
    $query = "nextval('app_reports_mgmt.reports_rid_seq') as nxt";
    $next_rid = Reports::selectRaw($query)->value('nxt');
    Session::put('next_rid', $next_rid);

    // load the view and pass the reports
    return View::make('templates.reports')
        ->with('reports', $reports);
}