hi
i have problems reading an oracle(9i) clob from a php-script with the
MDB-class from pear.
the table files has 3 fields:
id integer
document clob
picture clob
an entry is written to the table with the following code :
require_once('.....pear\MDB.php');
$mdb=&MDB::connect('oci8://user:pw@db');
...
$str_prepStat = 'INSERT INTO files VALUES (1,?,NULL)';
$preparedQuery = $mdb->prepareQuery($str_prepStat);
if(!MDB::isError($preparedQuery))
{
$clobData1 = array(
'Error'=>'',
'Data'=>'some lob data'
);
$clob1 = $mdb->createLob($clobData1);
$mdb->setParamClob($preparedQuery, 1, $clob1, 'document');
if(!MDB::isError($error = $mdb->executeQuery($preparedQuery)))
{
echo 'ok<br>';
$mdb->destroyLob($clob1);
}
else
{
echo $error->getMessage();
}
}
the entry definitly is in the table as i can see when i use sqlplus.
now all i would like to do is to read this content of this line back
into php, i use the following script, taken from the docs that come
with the MDB-bundle (slightly modified/echos inserted):
if(($result=$mdb->query("SELECT document FROM files WHERE id=1")))
{
if($mdb->endOfResult($result))
{
echo "No rows where returned.\n";
}
else
{
echo 'rows <br>';
$clob=$mdb->fetchClob($result,0,"document");
if(!MDB::isError($clob))
{
echo '!MDB::isError($clob) = true, $mdb->endOfLOB($clob) :
'.$mdb->endOfLOB($clob).'<br>';
while(!$mdb->endOfLOB($clob))
{
echo ' t<br>';
if(MDB::isError($error = $mdb->readLob($clob,$data,8000)<0))
{
echo $error->getMessage();
break;
}
else
{
echo 'error in readlob';
}
echo $data;
}
$mdb->destroyLob($clob);
}
else
{
echo '!MDB::isError($clob) = false<br>';
echo 'error in clob<br>';
echo $clob->getMessage();
}
}
$mdb->freeResult($result);
}
else
{
echo $result->getMessage();
}
when executed the message is :error in readlob, which i have no
explanation for?
has anyone had similar problems and/or can help me ?