Linux odbc致命错误:允许的内存大小 [英] Linux odbc Fatal error: Allowed memory size

查看:143
本文介绍了Linux odbc致命错误:允许的内存大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在设置AS400(iseries V6R1)和Debian之间的odbc链接时遇到一些问题,我使用iseriesAccess7.1 odbc驱动程序64位,unixODBC2.3.1和php5.4以及unixODBC支持.

I currently have some problems to set up an intranet with an odbc link beetween an AS400 (iseries V6R1) and a Debian I use the iseriesAccess7.1 odbc driver 64bits, unixODBC2.3.1 and php5.4 with unixODBC support.

我的链接似乎很好,因为我可以使用isql命令(它是unixODBC的一部分)连接到我的数据库并执行一些SQL查询,但是无法使用php脚本读取数据库中的记录. 当我尝试在Intranet上启动一个小脚本时,出现以下错误:

My link seems to be good because I can connect to my DataBase using the isql command (which is part of unixODBC) and execute some SQL queries but it's impossible to read records in the database using a php script. When I try to launch a little script on my intranet I get the following error :

致命错误:在第122行的/home/www/imypdo/imypdo.php中,已用完的内存大小为134217728字节(尝试分配493921239296字节)

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 493921239296 bytes) in /home/www/imypdo/imypdo.php on line 122

超过450 Gb!在/var/log/messages和/etc/httpd/logs/error_log

that's more than 450 Gb !! and nothing in /var/log/messages and in /etc/httpd/logs/error_log

一个简单的sql查询(select中仅包含1行)将返回一些奇怪的字符(请参阅下文),并且一旦我选择了1或2行,就会发生内存大小错误.

A simple sql query (with only 1 row in the select) will return some strange characters (see below) and as soon as I select 1 or 2 more rows the memory size error occurs.

[0] =>数组([ADHMAR] => AAAAAAA a @YÿŒ4-X0!ÿŒ4làÿŒ4làÿŒ4!)

[0] => Array ( [ADHMAR] => AAAAAAA a@YÿŒ4–X 0!ÿŒ4làÿŒ4làÿŒ4! )

我几乎可以确定这是与64位驱动程序相关的问题,因为我已经将另一个Debian与该iseries链接在一起,但是与32位驱动程序相关联,并且它运行良好. 奇怪的是,isql命令正在运行,而日志文件中什么也没有...

I'm almost sure it's a 64bit driver related problem because I already have another Debian linked with this iseries but with the 32 bit driver and it works perfectly. What is weird is that isql command is working and ther is nothing in the log files...

如果确实是64位驱动程序问题,我如何向IBM证明呢?

if it really is a 64 bit driver problem, how can I prove it to IBM ?

任何帮助将不胜感激

谢谢

---------------------------要连接的类----------------- -----------

--------------------------- Class to connect ----------------------------

private $_bdd = "DSN=db2;",
        $_user = "USERNAME",
        $_pwd = "Password";

private $_con,
        $_isConnected;


public function open_connection(){
    $this->_con = odbc_connect ($this->_bdd, $this->_user, $this->_pwd ) or die("Error Connection") ;
    $this->_isConnected = true;
}

public function close_connection(){
     odbc_close($this->_con);
     $this->_isConnected = false;
}

public function execute($sql){

    if(!($this->_isConnected))
        $this->open_connection();

    #execute sql
    $res = odbc_exec($this->_con, $sql);

    return $res;
}

public function fetchRow($res){

    $row = odbc_fetch_array($res);
    return $row;
}

}

---------------------------------查询脚本------------ ------------------

--------------------------------- Query Script ------------------------------

public function getPhoneLogsByDate($startDate, $endDate) {

    $startDate  = date('Ymd', strtotime($startDate));
    $endDate    = date('Ymd', strtotime($endDate));

    $rr = new As400_Model_as400query();

    $rr->open_connection();

    $sql = "select trim(tluser) as USER, trim(tlacct) as CLIENT, trim(concat(concat(concat(concat(concat(concat(substr(trim(tldate),1,4),'-'),substr(trim(tldate),5,2)),'-'),substr(trim(tldate),7,2)),' '), concat(concat(concat(concat(substr( substr(trim(tltime+1000000),2,6),1,2),':'),substr(substr(trim(tltime+1000000),2,6),3,2)),':'), substr(substr(trim(tltime+1000000),2,6),5,2)))) as DATETIME 
            ,trim(concat(concat(concat(concat(concat(concat(concat(concat(concat(concat(trreas,'|'),trsr01),'|'),trsr02),'|'),trsr03),'|'),trsr04),'|'),trsr05)) as REASONS
            ,trim(concat(concat(concat(tnnot1,tnnot2),tnnot3),tnnot4)) as NOTES

            from cabledta.tlogmstr left join cabledta.tlogreas on trnum#=tlnum#  left join cabledta.tlognote on tnnum#=tlnum#
            where tldate>='".$startDate."' and tldate <='".$endDate."'";



    $res = $rr->execute($sql);

    $response = array();


    while ($row = $rr->fetchRow($res)){

        $response[] = array(

                                'userName'      => $row['USER'],
                                'clientNumber'  => $row['CLIENT'],
                                'logDateTime'   => $row['DATETIME'],
                                'logReasons'    => $row['REASONS'],
                                'logNotes'      => utf8_encode($row['NOTES'])

                            );

    }
    $rr->close_connection();

return $response;
}

推荐答案

我知道了.

在64位版本中,当返回字段之一为NULL时,odbc崩溃. 因此,解决方法是在检索查询时替换所有空字段.

In the 64bit version the odbc crashs when one of the return fields are NULL. So the work around is to replace all the null fields when retriving the query.

示例:

从database.table中以USER身份选择ifnull(tluser,'')

select ifnull(tluser,'') as USER from database.table

这篇关于Linux odbc致命错误:允许的内存大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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