1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
try
{
$stid = oci_parse($conn, $query);
if (!$stid)
{
$e = oci_error($conn);
$msg_err = 'ERROR: Oracle query parse: '. htmlentities($e['message'], ENT_QUOTES);
echo $msg_err;
error_log($msg_err.';Date:' .date("d/m/Y H:i:s").';'.'Username:' .$user_name.chr(13), 3, $log_folder.$log_error);
exit;
}
$result = oci_execute($stid);
if (!$result)
{
$e = oci_error($conn);
$msg_err = 'ERROR: Oracle query execute: '. htmlentities($e['message'], ENT_QUOTES);
echo $msg_err;
error_log($msg_err.';Date:' .date("d/m/Y H:i:s").';'.'Username:' .$user_name.chr(13), 3, $log_folder.$log_error);
exit;
}
}
catch(ErrorException $ex)
{
$msg_err = 'ERROR: '. htmlentities($ex->getMessage(), ENT_QUOTES);
echo $msg_err;
error_log($msg_err.';Date:' .date("d/m/Y H:i:s").';'.'Username:' .$user_name.chr(13), 3, $log_folder.$log_error);
exit;
}
restore_error_handler();
$row = Oci_fetch_array($stid,OCI_RETURN_NULLS);
if (!is_array($row))
{
echo 'ERROR: NORECORD';
exit;
}
$line = "";
$comma = "";
foreach($row as $name => $value)
{
$line .= $comma . '"' . str_replace('"', '""', $name) . '"';
$comma = ";";
}
$line .= "\n";
$out = $line;
while($row = Oci_fetch_array($stid,OCI_RETURN_NULLS))
{
$line = "";
$comma = "";
foreach($row as $value)
{
$line .= $comma . '"' . str_replace('"', '""', $value) . '"';
$comma = ";";
}
$line .= "\n";
$out.=$line;
}
// Renvoi du resultat
echo $out; |
Partager