Oracle_query() and Other Oracle Convenience Functions

Attached File(s): 

If you're used to using MySQL with PHP, you already know of the simple and easy to use mysql_query(), mysql_fetch_object(), mysql_affected_rows() and so forth functions.  Well, if you've ever dipped your toes into the tepid waters of Oracle, you know that it lacks the friendly PHP functions that MySQL has.  So, I created a set of convenience functions designed to mirror the MySQL ones.

Just download the attached file at the top, and use it 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();
  
?>

Just remember that to use any of this, you also need PHP to be compiled with the necessary oci libraries.

Complete list of functions in the file:

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

Enjoy!

 


Software License Fine Print

Creative Commons LicenseThis code is licensed as-is, with no warranty or guarantee, under a Creative Commons Attribution 3.0 Unported License.

You may use this code however you want, even in commercial products, but only if you include attribution to me, Richard Peacock, as the original author of this small portion of code, but not in a way that implies I endorse your project.

For example, on a Help/Credits screen:  Portions of this project were based on work freely obtained from these developers: Richard Peacock (http://richardpeacock.com), NAME HERE, etc.  These outside developers neither endorse nor support this software.

If you use this code, feel free to email me to let me know!  I'll include a link to your project here.