List:General Discussion« Previous MessageNext Message »
From:sam1600 Date:April 15 1999 10:18am
Subject:Coverting a postgess blob to Mysql?
View as plain text  
Hello,
Thanks all for the help on my last question!
...
The code below is from a program using Postgres.
This may be too PHP related but I hope not.  In my continuly
frustrating attempt to port this program to Mysql I come 
accross the  following three functions and I'm having 
*trouble* with the following lines:

SELECT lo_import('$file')
#"pg_lo_import reads the specified file and places the contents
#into a large object."

$query="SELECT lo_export($oid::oid,'$file')";
#"pg_lo_export writes the specified large object into a Unix file."


$query="SELECT lo_unlink($oid)";
#"pg_lo_unlink deletes the specified large object."

Postgres's OID is an automatically assigned unique Object ID for
each row and I'm useing Auto_increment as a "possible" subsitute.

Asking for advice on this may be a bit soon as I don't
fully undersand how Postgress handles Blob's but I think
that it's buitin lo* function could be replaced by
php Read/write and then load the blob ito Mysql like any
other... with escaping a Read_file_in for instance (or not)
... if so how exactly, as it pertains to the functions
below?  I may sound here like I might know what I'm talkig
about but not really ;-)

One last question, What is the double colons for in the
line:
$query="SELECT lo_export($oid::oid,'$file')";

Thanks ALOT! 
-Sam

function createBLOB($file)
{
  global $erreur_qChamps;

  if($file!="none") {
    $query="SELECT lo_import('$file')";
    //echo("$query<BR>\n");
    $result=execQuery($query,$erreur_qChamps);
    unlink($file);
    return getVal($result,0,0);
  }
}

//==========================================================================

function printBLOB($oid)
{
  global $erreur_qChamps;

  $file=uniqid("/var/tmp/");

  $query="SELECT lo_export($oid::oid,'$file')";
  //echo("$query<BR>\n");
  $result=execQuery($query,$erreur_qChamps);

  readfile($file);

  unlink($file);
}

//==========================================================================
function eraseBLOB($oid)

{
  global $erreur_qChamps;

  $query="SELECT lo_unlink($oid)";
  //echo("$query<BR>\n");
  $result=execQuery($query,$erreur_qChamps);
}




----------------------------------------------------------------
Get your free email from AltaVista at http://altavista.iname.com
Thread
Coverting a postgess blob to Mysql?sam160015 Apr