mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-11 00:18:25 +01:00
This patch adds full Support for the bytea-datatype, wich is missing from PHP itself. I should have known this, before adding the datatype to schemaproc, but well ... here's the fix.
This commit is contained in:
parent
380c117f8e
commit
7dcab6a1b0
@ -4,8 +4,8 @@
|
||||
* Copyright (c) 1998,1999 SH Online Dienst GmbH Boris Erdmann, *
|
||||
* Kristian Koehntopp *
|
||||
* ------------------------------------------------------------------------ *
|
||||
* This is not part of phpGroupWare, but is used by phpGroupWare. *
|
||||
* http://www.phpgroupware.org/ *
|
||||
* This is not part of phpGroupWare, but is used by phpGroupWare. *
|
||||
* http://www.phpgroupware.org/ *
|
||||
* ------------------------------------------------------------------------ *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as published *
|
||||
@ -22,6 +22,8 @@
|
||||
// PostgreSQL changed somethings from 6.x -> 7.x
|
||||
var $db_version;
|
||||
|
||||
var $_byteaArray;
|
||||
|
||||
function ifadd($add, $me)
|
||||
{
|
||||
if($add != '')
|
||||
@ -170,6 +172,8 @@
|
||||
$this->halt('Invalid SQL: ' . $Query_String, $line, $file);
|
||||
}
|
||||
|
||||
$this->_init_bytea_array();
|
||||
|
||||
return $this->Query_ID;
|
||||
}
|
||||
|
||||
@ -216,6 +220,12 @@
|
||||
pg_freeresult($this->Query_ID);
|
||||
$this->Query_ID = 0;
|
||||
}
|
||||
|
||||
if (isset($this->_byteaArray))
|
||||
{
|
||||
$this->_fixbytea();
|
||||
}
|
||||
|
||||
return $stat;
|
||||
}
|
||||
|
||||
@ -547,5 +557,40 @@
|
||||
$this->Database = $currentDatabase;
|
||||
$this->connect();
|
||||
}
|
||||
}
|
||||
|
||||
// cache types for blob decode check in a class-member called "_byteaArray"
|
||||
function _init_bytea_array()
|
||||
{
|
||||
for ($i=0, $max = @pg_numfields($this->Query_ID); $i < $max; $i++)
|
||||
{
|
||||
if (@pg_fieldtype($this->Query_ID, $i) == 'bytea')
|
||||
{
|
||||
$this->_byteaArray[$i] = @pg_fieldname($this->Query_ID, $i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _fixbytea()
|
||||
{
|
||||
foreach($this->_byteaArray as $k => $v)
|
||||
{
|
||||
$this->Record[$k] = $this->_bytea_decode($this->Record[$k]);
|
||||
}
|
||||
foreach($this->_byteaArray as $k => $v)
|
||||
{
|
||||
if (!isset($this->Record[$v]))
|
||||
{
|
||||
$this->Record = false;
|
||||
return;
|
||||
}
|
||||
$this->Record[$v] = $this->_bytea_decode($this->fields[$v]);
|
||||
}
|
||||
}
|
||||
|
||||
// fix data from bytea-fields, wich are not fully supported by PHP itself
|
||||
function _bytea_decode($bytea)
|
||||
{ echo "I'm called because of $bytea <br>";
|
||||
eval('$realbytea="'.str_replace(array('"','$'),array('\"','\$'),$bytea).'";');
|
||||
return $realbytea;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user