To enable PHP to use the edb-odbc driver, PHP must be compiled with the unixODBC Driver Manager
and deployed as an Apache shared module. A detailed reference of this procedure is hosted as
part of the unixODBC site found at http://www.unixodbc.com/doc/php3.html.
Once PHP is properly configured, the following script connecting to the EnterpriseDB
sample database can be used as a sample to further development.
<?php
print("<html>\n");
$selectQuery = "SELECT to_char(sysdate, 'yyyymmdd hh24:mi:ss'), empno, ename,
job FROM emp WHERE empno > 7900";
$insertStmt="INSERT INTO emp(empno,ename, sal, deptno) VALUES(8000,'SHARK', 100, 20)";
$updateStmt="UPDATE emp SET job = 'DBA' where empno = 8000";
$storedProcStmt="EXEC select_emp(8000)";
$deleteStmt="DELETE FROM emp WHERE empno = 8000";
$connect = odbc_connect("EnterpriseDB", "edb", "edb");
print("--------------------Test 1----------------------------------<br>\n");
print("Executing Query: $selectQuery<br>\n");
$result = odbc_exec($connect, $selectQuery);
print("--Results:<br>\n");
print("<table>\n");
while(odbc_fetch_row($result)){
print("<tr>\n");
$currtime = odbc_result($result, 1);
print("<td>$currtime</td>\n");
$empno = odbc_result($result, 2);
print("<td>$empno</td>\n");
$ename = odbc_result($result, 3);
print("<td>$ename</td>\n");
$job = odbc_result($result, 4);
print("<td>$job</td>\n");
print("</tr>\n");
}
print("</table>\n");
print("--------------------Test 2----------------------------------<br>\n");
print("Executing Query: $insertStmt<br>\n");
$result = odbc_exec($connect, $insertStmt);
print("--------------------Test 3----------------------------------<br>\n");
print("Executing Query: $updateStmt<br>\n");
$result = odbc_exec($connect, $updateStmt);
print("--------------------Test 4----------------------------------<br>\n");
print("Executing Query: $storedProcStmt<br>\n");
$result = odbc_exec($connect, $storedProcStmt);
print("$results <br>");
print("--------------------Test 5----------------------------------<br>\n");
print("Executing Query: $deleteStmt<br>\n");
$result = odbc_exec($connect, $deleteStmt);
odbc_close($connect);
print("</html>\n");
?>