2016-11-22 123 views
0

有谁知道如何将hive数据库连接到YII框架?对于ODBC连接,YII的文档提供了以下代码。但它不起作用。yii与hive数据库的数据库连接

array(
    ...... 
    'components'=>array(
     ...... 
     'db'=>array(
      'class'=>'CDbConnection', 
      'connectionString'=>'mysql:host=localhost;dbname=testdb', 
      'username'=>'root', 
      'password'=>'password', 
      'emulatePrepare'=>true, // needed by some MySQL installations 
     ), 
    ), 
) 

回答

0

为ODBC,你可以使用http://www.yiiframework.com/doc/guide/1.1/it/database.dao

使用ODBC时,它的连接字符串(DSN)不表示唯一 什么数据库类型来使用(MySQL和MS SQL Server等)。因此它不能自动检测所需的DBMS特定类 (CMysqlSchema,CMssqlSchema等)。

这就是为什么你必须使用CDbConnection类的$ DriverName属性的歧义是:

array(
    ...... 
    'components'=>array(
    ...... 
    'db'=>array(
     'class'=>'CDbConnection' 
     'driverName'=>'mysql', 
     'connectionString'=>'odbc:Driver={MySQL};Server=127.0.0.1;Database=test', 
     'username'=>'', 
     'password'=>'', 
    ), 
), 
) 
+0

我想这也有,但是它不建立 –

+0

你设置好的正确的数据库连接,用户名和密码? – scaisEdge