Ejemplo n.º 1
0
function DB_lo_import($conn, $file)
{
    if (strcmp(phpversion(), '4.2.0') < 0) {
        return pg_loimport($file, $conn);
    } else {
        return pg_lo_import($conn, $file);
    }
}
Ejemplo n.º 2
0
 public function insertblob($filename)
 {
     $this->query = pg_query($this->dbhandle, "begin");
     $blob = pg_lo_import($this->dbhandle, $filename);
     pg_query($this->dbhandle, "commit");
     return $blob;
     //TODO: kontola, ali je bil query ok izveden!
 }
Ejemplo n.º 3
0
 public function execute(Pg $pg, $simulate = false)
 {
     if (!$this->object->isChanged()) {
         return true;
     }
     // IMPORTANT: pg_lo_import/export DO NOT WORK without a transaction!
     $pg->query(new Query('BEGIN'));
     if (!($oid = pg_lo_import($pg->resource->get(), $this->object->getFilePath()))) {
         throw new QueryException('Unable to import PgLargeObject');
     }
     // IMPORTANT: pg_lo_import/export DO NOT WORK without a transaction!
     $pg->query(new Query('COMMIT'));
     $this->object->markPersisted($oid);
     return true;
 }
Ejemplo n.º 4
0
	function lo_import($file){
		return pg_lo_import($this->resource, $file);
	}
Ejemplo n.º 5
0
 function importLargeObject($path)
 {
     $connection = $this->connect(NULL);
     // Large objects calls MUST be enclosed in transaction block
     // remember, large objects must be obtained from within a transaction
     pg_query($connection, "begin");
     $new_oid = pg_lo_import($connection, $path);
     // committing the data transaction
     pg_query($connection, "commit");
     return $new_oid;
 }
Ejemplo n.º 6
0
 function UpdateBlobFile($table, $column, $val, $where, $blobtype = 'BLOB')
 {
     pg_exec($this->_connectionID, "begin");
     $oid = pg_lo_import($val);
     pg_exec($this->_connectionID, "commit");
     $rs = ADOConnection::UpdateBlob($table, $column, $oid, $where, $blobtype);
     $rez = !empty($rs);
     return $rez;
 }
Ejemplo n.º 7
0
 public function loImport($pathname, $object_id = null)
 {
     assert('is_string($pathname)');
     assert('is_int($object_id) || is_null($object_id)');
     return pg_lo_import($this->_pg, $pathname, $object_id);
 }
Ejemplo n.º 8
0
 function lo_import($p_oid)
 {
     return pg_lo_import($this->db, $p_oid);
 }
Ejemplo n.º 9
0
if (!$oid) {
    echo "pg_lo_import() error\n";
}
if ($oid != 21003) {
    echo "pg_lo_import() wrong id\n";
}
pg_lo_unlink($db, $oid);
pg_exec($db, 'commit');
echo "import LO from string\n";
pg_exec($db, 'begin');
$oid = pg_lo_import($db, __FILE__, "21004");
if (!$oid) {
    echo "pg_lo_import() error\n";
}
if ($oid != 21004) {
    echo "pg_lo_import() wrong id\n";
}
pg_lo_unlink($db, $oid);
pg_exec($db, 'commit');
echo "import LO using default connection\n";
pg_exec('begin');
$oid = pg_lo_import($db, __FILE__, 21005);
if (!$oid) {
    echo "pg_lo_import() error\n";
}
if ($oid != 21005) {
    echo "pg_lo_import() wrong id\n";
}
pg_lo_unlink($oid);
pg_exec('commit');
echo "OK";
Ejemplo n.º 10
0
pg_lo_close($handle);
pg_exec($db, "commit");
echo "unlink LO\n";
pg_exec($db, "begin");
pg_lo_unlink($db, $oid) or print "pg_lo_unlink() error 1\n";
pg_exec($db, "commit");
// more pg_lo_unlink() tests
echo "Test without connection\n";
pg_exec($db, "begin");
$oid = pg_lo_create($db) or print "pg_lo_create() error\n";
pg_lo_unlink($oid) or print "pg_lo_unlink() error 2\n";
pg_exec($db, "commit");
echo "Test with string oid value\n";
pg_exec($db, "begin");
$oid = pg_lo_create($db) or print "pg_lo_create() error\n";
pg_lo_unlink($db, (string) $oid) or print "pg_lo_unlink() error 3\n";
pg_exec($db, "commit");
echo "import/export LO\n";
$path = dirname(__FILE__) . '/';
pg_query($db, 'begin');
$oid = pg_lo_import($db, $path . 'php.gif');
pg_query($db, 'commit');
pg_query($db, 'begin');
@unlink($path . 'php.gif.exported');
pg_lo_export($oid, $path . 'php.gif.exported', $db);
if (!file_exists($path . 'php.gif.exported')) {
    echo "Export failed\n";
}
@unlink($path . 'php.gif.exported');
pg_query($db, 'commit');
echo "OK";