mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-24 03:41:53 +02: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
@ -22,6 +22,8 @@
|
|||||||
// PostgreSQL changed somethings from 6.x -> 7.x
|
// PostgreSQL changed somethings from 6.x -> 7.x
|
||||||
var $db_version;
|
var $db_version;
|
||||||
|
|
||||||
|
var $_byteaArray;
|
||||||
|
|
||||||
function ifadd($add, $me)
|
function ifadd($add, $me)
|
||||||
{
|
{
|
||||||
if($add != '')
|
if($add != '')
|
||||||
@ -170,6 +172,8 @@
|
|||||||
$this->halt('Invalid SQL: ' . $Query_String, $line, $file);
|
$this->halt('Invalid SQL: ' . $Query_String, $line, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_init_bytea_array();
|
||||||
|
|
||||||
return $this->Query_ID;
|
return $this->Query_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,6 +220,12 @@
|
|||||||
pg_freeresult($this->Query_ID);
|
pg_freeresult($this->Query_ID);
|
||||||
$this->Query_ID = 0;
|
$this->Query_ID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($this->_byteaArray))
|
||||||
|
{
|
||||||
|
$this->_fixbytea();
|
||||||
|
}
|
||||||
|
|
||||||
return $stat;
|
return $stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,5 +557,40 @@
|
|||||||
$this->Database = $currentDatabase;
|
$this->Database = $currentDatabase;
|
||||||
$this->connect();
|
$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…
x
Reference in New Issue
Block a user