PHP Classes

File: database.example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Peter Pivarc  >  PHP Oracle Stored Procedures  >  database.example.php  >  Download  
File: database.example.php
Role: Example script
Content type: text/plain
Description: example script
Class: PHP Oracle Stored Procedures
Execute Oracle SQL queries and stored procedures
Author: By
Last change:
Date: 1 year ago
Size: 1,472 bytes


Class file image Download

require_once "database.class.php";

$db = new database("username", "password", "connection_string");

 * to select something from database
 * ie. current date
$sql = "select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') as \"DATE\" from dual";
$ret = $db->select($sql);

"Current date: " . $ret['DATE'][0];


 * to update record
$sql = "update table_name set col_name = new_value";

 * to run stored procedure (function) that return user defined data type
 * note: auto binding will be used for :data_collection_myvarchar2list
 * note: function function_name is returning data type myvarchar2list (not case sensitive)
 * note: name convency is used... :data | collection | myvarchar2list
 * :data = name for array key where records are returned
 * collection = returned records are collection
 * myvarchar2list = collection name
$sql = ":data_collection_myvarchar2list := package_name.function_name(parameter);";
$ret = $db->procedure($sql);

 * other procedure example - returning sys_refcursor
 * note: name convency is used... :records | cur
 * :records = name for array key where records are returned
 * cur = returned data type is cursor
 * note: allowed built-in datatypes supported can be found in getTypeByName method of database class
$sql = ":records_cur := package_name.function_name(parameter);";
$ret = $db->procedure($sql);