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.
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 :
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 493921239296 bytes) in /home/www/imypdo/imypdo.php on line 122
that's more than 450 Gb !! and nothing in /var/log/messages and in /etc/httpd/logs/error_log
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] => Array ( [ADHMAR] => AAAAAAA a@YÿŒ4–X 0!ÿŒ4làÿŒ4làÿŒ4! )
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...
if it really is a 64 bit driver problem, how can I prove it to IBM ?
any help will be appreciated
thanks
--------------------------- 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;
}