laravel5.5 里面如果想要使用自定义的数据库连接器

2023-12-13 16:15:14

由于项目里面使用到了doris,虽然doris支持mysql协议,但是如果直接把他当mysql使用是行不通的,因为doris并不支持mysql的一些option和mode设置,然后就会一直报错:

SQLSTATE[HY000]: General error: 2013 Lost connection to MySQL server during query (SQL: select sum(totalvisit) total_visit,hour time from `xxx` where `date` between 2023-12-05 and

追踪代码,一直查到

    public function createConnector(array $config)
    {
   
        if (! isset($config['driver'])) {
   
            throw new InvalidArgumentException('A driver must be specified.');
        }

        if ($this->container->bound($key = "db.connector.{
     $config['driver']}")) {
   
            return $this->container->make($key);
        }

        switch ($config['driver']) {
   
            case 'mysql':
                return new MySqlConnector;
            case 'pgsql':
                return new PostgresConnector;
            case 'sqlite':
                return new SQLiteConnector;
            case 'sqlsrv':
                return new SqlServerConnector;
        }

        throw new InvalidArgumentException("Unsupported driver [{
     $config['driver']}]"

文章来源:https://blog.csdn.net/zhezhebie/article/details/134972136
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。