gpt4 book ai didi

php - Linux odbc fatal error : Allowed memory size

转载 作者:搜寻专家 更新时间:2023-10-31 20:41:09 25 4
gpt4 key购买 nike

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

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

fatal error :在第 122 行的/home/www/imypdo/imypdo.php 中允许的 134217728 字节的内存大小已耗尽(试图分配 493921239296 字节)

超过 450 Gb !!/var/log/messages 和/etc/httpd/logs/error_log 中没有任何内容

一个简单的 sql 查询(选择中只有 1 行)将返回一些奇怪的字符(见下文),一旦我再选择 1 或 2 行,就会发生内存大小错误。

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

我几乎可以肯定这是一个与 64 位驱动程序相关的问题,因为我已经有另一个 Debian 链接到这个系列,但使用 32 位驱动程序并且它工作得很好。奇怪的是 isql 命令正在运行,但日志文件中没有任何内容...

如果真的是 64 位驱动问题,我如何向 IBM 证明?

任何帮助将不胜感激

谢谢

------------------------ 连接类---------------- ----------

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

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

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 会崩溃。因此,解决方法是在检索查询时替换所有空字段。

例子:

从数据库表中选择 ifnull(tluser,'') 作为 USER

关于php - Linux odbc fatal error : Allowed memory size,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21286589/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com