Oracle_query() and Other Oracle Convenience Functions

Oracle_query() and Other Oracle Convenience FunctionsIf you're used to using MySQL with PHP, you already know of the simple and easy to use functions like mysqli_query(), mysqli_fetch_object(), mysqli_affected_rows() and so forth.  But, if you've ever gone to query from an Oracle database, you've no doubt noticed that Oracle's oci_* functions are much less pleasant. 

So, I decided to create a set of functions similar to mysqli.

 

Complete List of Functions

oracle_connect()
oracle_query()
oracle_fetch_array()
oracle_fetch_object()
oracle_affected_rows()
oracle_close()
oracle_error()
oracle_errno()
oracle_escape_string()

 

How Do I Use It?

Download the php file from here (and rename to .php).

Next, you would use it in your code like so:

<?php
  
  include_once("oracle_common_functions.php");

  oracle_connect($username, $pass, $host, "TEST");
  $res = oracle_query(" SELECT * FROM $table_name ") or echo(oracle_error());
  while ($cur = oracle_fetch_array($res)) {
    var_dump($cur);
  }  
  
  oracle_close();

 

Copyright and Disclaimer

This code is licensed as-is, with no warranty or guarantee, under Creative Commons Attribution 3.0 Unported License.  In other words, you may use this code however you like, even in a commercial product. I just ask that on a Help or Credits file/screen, you attribute myself as the original author.

Example: Portions of this project were based on work freely obtained from: Richard Peacock (https://peacocksoftware.com), NAME HERE, NAME HERE, etc.  Their work included here does not imply they endorse or support this project.