laravel DB::connection()->getPdo()::PARAM_STR not working

烈酒焚心 提交于 2019-12-11 04:34:11

问题


The function getPdo() with PARAM_STR in laravel

DB::connection()->getPdo()::PARAM_STR

is working fine with php 7.0.0 but not working with php 5.6.16 or lesser versions. How can I get the PARAM_STR from PDO instance in laravel with php 5.6.16 or less?

I have tried

DB::connection()->getPdo()->PARAM_STR

but not working for me..


回答1:


The solution which worked for me is this..

static function db ()
    {
        try {
            $db = DB::connection()->getPdo();
        }
        catch (PDOException $e) {
            self::fatal(
                "An error occurred while connecting to the database. ".
                "The error reported by the server was: ".$e->getMessage()
            );
        }
        return $db;
    }

By calling..

$db=self::db();

$db::PARAM_STR

I got it solved. All inside class & method



来源:https://stackoverflow.com/questions/38076065/laravel-dbconnection-getpdoparam-str-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!