• Here is the process to work with Word Press using Oracle DB.

    this function to make a connection, do a query and show the results (example uses the Resources schema that comes with Oracle Express):

    function MyOracleConnection ()
    
    {
    
    $conn = oci_connect('hr', 'tester', 'localhost/XE');
    
    if (!$conn) {
    
        $e = oci_error();
    
        trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
    
             }
    
             else     {
    
             echo '<p>Congrats: Oracle meets WordPress!</p>';
    
    }
    
    // Prepare the statement
    
    $stid = oci_parse($conn, 'SELECT * FROM departments');
    
    if (!$stid) {
    
        $e = oci_error($conn);
    
        trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
    
    }
    
    // Perform the logic of the query
    
    $r = oci_execute($stid);
    
    if (!$r) {
    
        $e = oci_error($stid);
    
        trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
    
    }
    
    // Fetch the results of the query
    
    print "<table border='1'>\n";
    
    while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
    
        print "<tr>\n";
    
        foreach ($row as $item) {
    
           print "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "?") . "</td>\n";
    
        }
    
        print "</tr>\n";
    
    }
    
    print "</table>\n";
    
    oci_free_statement($stid);
    
    oci_close($conn);
    
    }

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your posted code may now have been permanently damaged/corrupted by the forum’s parser.]

    You can then use this function in your WordPress template to do the magic.

    You can read more about the use of OCI8 here:
    https://php.net/manual/en/book.oci8.php

  • The topic ‘Install Worpress with Oracle DB’ is closed to new replies.