<?php
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);
echo "Current date: " . $ret['DATE'][0];
echo "<br>";
/**
* to update record
*/
$sql = "update table_name set col_name = new_value";
$db->update($sql);
/**
* 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);
?>
|