Mit PHP auf Oracle zugreifen
Beitrag geschrieben von PriHost am 2008-01-23
Kurzbeschreibung:
Mit PHP auf Oracle zugreifen
Mit PHP auf Oracle zugreifen
Ein einfaches PHP-Beispiel zur Datenbankanbindung zu Oracle.
Code:
<html>
<body>
<?php
// open a connection
if (!$db = @ora_logon("scott@testdb29","tiger")) {
$error = ora_error();
printf("There was an connecting error. Error was: %s", $error);
exit();
}
else
echo "Connect...\n<br>";
$curs = ora_open($db);
$sql = "SELECT * FROM dept";
// check is that SQL statement is.
if (!@ora_parse($curs,$sql)) {
echo "Error in parse. Error was :", ora_error($curs);
} else {
ora_exec($curs);
// display results using the column offset
while (ora_fetch_into($curs, $results)) {
echo $results[0];
echo $results[1];
echo "<br>";
}
}
?>
</body>
</html>
<body>
<?php
// open a connection
if (!$db = @ora_logon("scott@testdb29","tiger")) {
$error = ora_error();
printf("There was an connecting error. Error was: %s", $error);
exit();
}
else
echo "Connect...\n<br>";
$curs = ora_open($db);
$sql = "SELECT * FROM dept";
// check is that SQL statement is.
if (!@ora_parse($curs,$sql)) {
echo "Error in parse. Error was :", ora_error($curs);
} else {
ora_exec($curs);
// display results using the column offset
while (ora_fetch_into($curs, $results)) {
echo $results[0];
echo $results[1];
echo "<br>";
}
}
?>
</body>
</html>


