laravel DB :: connection()-> getPdo():: PARAM_STR不起作用 [英] laravel DB::connection()->getPdo()::PARAM_STR not working

查看:558
本文介绍了laravel DB :: connection()-> getPdo():: PARAM_STR不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

laravel中具有PARAM_STR的getPdo()函数

The function getPdo() with PARAM_STR in laravel

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

在php 7.0.0上工作正常,但在php 5.6.16或更低版本下不能正常工作.如何在php 5.6.16或更低版本的laravel中从PDO实例获取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?

我尝试过

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

但不为我工作.

推荐答案

对我有用的解决方案是这个..

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;
    }

通过致电..

$db=self::db();

$db::PARAM_STR

我解决了.所有内部类方法

I got it solved. All inside class & method

这篇关于laravel DB :: connection()-> getPdo():: PARAM_STR不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆