Urgent, please!
I am working on a PHP & MySQL environment using Object Oriented Programming for all my development work. I have a challenge since I have a database which I would like to use, but it is in Oracle. Can anyone send me a class PHP convert Oracle MySQL so that I can have my system up and running? Thanks.
How can I use class PHP convert Oracle MySQL?
Hi Leonard,
As you mentioned that you are facing trouble working with Oracle and PHP on Object Oriented programming structure and want to know how can it works, I’m providing you the solution below:
Suppose we want to extend a built in class which is public to create XML documents. I’m giving you only the sample codes of accessing oracle database with PHP.
Code:
<?php
require_once 'Mydom.php';
require_once 'dbCon.php';
require_once 'ScottCred.php';
$i = 0;
try {
$dom1= new Mydom();
$root = $dom->addElement($dom1, 'EMPLOYEES');
$db = new dbCon($user, $pswd, $conn);
$sql="SELECT emp_no,e_name, job FROM EMP";
$db->query($sql);
while ($row = $db->fetch()) {
$empl = $dom1->addElement($root, 'EMPLOYEE');
$empl->setAttribute('id', ++$i);
$empno = $dom1->addElement($empl, 'emp_no', oci_result($row,'emp_no'));
$ename = $dom1->addElement($empl, 'e_name', oci_result($row,'e_name'));
$title = $dom1->addElement($empl, 'job', oci_result($row,'job'));
}
print $dom->saveXML();
}
catch(Exception $e) {
print $e->getMessage();
}
?>