1st
---
if you use php you can use the function:
"pg_escape_bytea()"
when you want to retrieve the data from db you have to use:
"pg_unescape_bytea()"
for unescaping it
see the php documentation on this function for more information
2nd
---
if you want to insert biiig data volumes try either using COPY instead
of INSERT - it will run much much faster
you can use implement somewhere this function to use it very easy in php:
/***********
$tableName - specifies the name of the table where the data has to be
copied into
$copyArr - contains "n" elements of rows to be inserted, sample
element:
array(
"col1" => "foo",
"col2" => "bar"
)
***********/
function copyInto($tableName,$copyArr) {
$thisDBConn = $this->getThisDBConnection(); // replace here your
retrieve to get your db connection into this variable
$queryCopyStart = "COPY ".$tableName." (";
// get out columns that has to be processed
$columnList = "";
$count = 0;
foreach ($copyArr[0] as $key=>$value) {
$count++;
if ($count!=1) {
$columnList .= ",";
}
$columnList .= $key;
}
$queryCopyStart .= $columnList.") FROM STDIN WITH DELIMITER AS '\\t'
NULL AS '' CSV QUOTE AS '\\'' ESCAPE AS '\\\\';\n";
$queryCopyData = Array();
$countLine = 0;
foreach ($copyArr as $lineKey=>$lineValue) {
$countLine++;
$thisLine = "";
$countData = 0;
foreach ($lineValue as $dataKey=>$dataValue) {
$countData++;
$thisLine .= "'".$dataValue."'";
if ($countData!=count($lineValue)) {
$thisLine .= chr(9);
}
}
$thisQueryCopyData = $thisLine."\n";
array_push($queryCopyData,$thisQueryCopyData);
}
$queryCopyEnd = "\\.\n";
pg_query($thisDBConn,$queryCopyStart);
pg_put_line($thisDBConn,implode("",$queryCopyData));
pg_put_line($thisDBConn,$queryCopyEnd);
pg_end_copy($thisDBConn);
}
be aware with the "max_stack_depth" value in postgresql.conf, maybe you
will need to increase it
Postgres Admin wrote:
Sorry for the attachment, but copying and pasting this data does not work.
I don't have any idea how to insert the type of data into PostgreSQL.
Basically, it's encrypted data in which I would like that keep raw format.
Thanks for any help,
J
------------------------------------------------------------------------
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match