Login   Register  
PHP Classes
elePHPant
Icontem

File: database.example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 2013-10-14 12:26
Size: 1,472 bytes
 

Contents

Class file image Download
<?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);

?>