问题
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