当我只使用odbc时,所有文件都会成功运行
$dsn = "DSN=DingdongImpala;host=172.168.1.100;port=21050;database=mmdb;";
$user = '';
$password = '';
$conn = odbc_connect($dsn, $user, $password);
$result = odbc_exec($conn, "select succount,failedcount,appid from t_mm_acc_date limit 1");
while($row = odbc_fetch_array($result)) {
print_r($row);
}
结果是:
Array
(
[succount] => 0 //int
[failedcount] => 1 //int
[appid] => 202361 //string
)
但是当我使用pdo访问odbc时,字符串类型字段都是空的
$dsn = "odbc:DSN=DingdongImpala;Host=172.168.1.100;Port=21050;database=mmdb;";
$user = '';
$password = '';
$cnx = new PDO($dsn, $user, $password);
$result = $cnx->query("select succount,failedcount,appid from t_mm_acc_date limit 1");
print_r($result->fetchObject());
结果是:
stdClass Object
(
[succount] => 100 //int
[failedcount] => 0 //int
[appid] => //string, empty
)
我试过很多例子,只要我从 Impala 中选择字符串字段,结果就会是空的,但int字段是正常的。
我的系统环境:
centos 6
PHP 5.3.6
php-odbc-5.3.3
unixODBC-2.2.14
ClouderaImpalaODBC-2.5.29.1009-1.el6.x86_64.rpm
1条答案
按热度按时间nnt7mjpx1#
我面临同样的问题,作为解决方法,我将字符串字段强制转换为varchar,如下所示: