Source for file ORACLE.phpclass
Documentation is available at ORACLE.phpclass
* Class file ORACLE.phpclass
* @project Open CSP-Management
* @author Peter Krebs <p.krebs@lvus.at>
* @copyright (c) 2002-2003 by Peter Krebs and Landesverlag Unternehmensservice
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* ORACLE database connection class
* @project Open CSP-Management
* @author Peter Krebs <p.krebs@lvus.at>
* @copyright (c) 2002-2003 by Peter Krebs and Landesverlag Unternehmensservice
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
#############################################
---------------------------------------------
#############################################
---------------------------------------------
##############################################
// ------------------------------------------
function connect($aUser,$aPassword,$aDatabase=
"",$aHost=
"localhost",$debug=
FALSE) {
if ($debug) echo
"<p><b>ORACLE::connect($aUser,\$aPassword,$aDatabase,$aHost ...)</b></p>";
if ($this->dbConnId =
OCILogon($aUser,$aPassword,$aDatabase)) {
// ------------------------------------------
// ------------------------------------------
##############################################
// ------------------------------------------
function query($aQuery=
"",$withErrMsg=
FALSE) {
if ($aQuery ==
"") return FALSE;
if ($cursor =
@OCIParse($this->dbConnId,$aQuery)) {
if (@OCIExecute($cursor,OCI_DEFAULT)) {
echo
"<hr>COULD NOT PARSE:<br>$aQuery<hr>";
// ------------------------------------------
* returns (a column) of the first row match
* if $colNr > -1 the column value at position $colNr in
* the select statement is returned (NOTE: index starts at 0)
* if $colNr < 0 a array is returend
* if $usNames the DB-column names are the index otherwise
* the index of the returned are is the number in the select order
* @param bool $withErrMsg
* @todo $secMode not implemented
function quickQuery($aQuery,$colNr=-
1,$withErrMsg=
FALSE,$useNames=
TRUE,$secMode=
TRUE,$debug=
FALSE) {
if ($debug) echo
"<p><b>DB_ORA::quickQuery($aQuery,$colNr,$withErrMsg,$useNames,$secMode,$debug)</b></p>";
if ($cursor =
OCIParse ($this->dbConnId, $aQuery)) {
$fMode=
OCI_RETURN_NULLS+
OCI_RETURN_LOBS;
if ($useNames) $fMode+=
OCI_ASSOC;
else $fMode=
$fMode+=
OCI_NUM;
$arr=
$this->fetchArray($cursor,$fMode,$debug); /* <pk-04-11-17/> */
OCIFreeStatement ($cursor);
if ($debug) echo
"<blockquote><p>Result:</p><pre>".
print_r($arr,TRUE).
"</pre></blockquote>";
foreach($arr as $key=>
$val) {
if ($debug) echo
"<blockquote><p>Returns:<br />".
$this->convertString($val).
"</p></blockquote>";
foreach($arr as $key =>
$val) {
// ------------------------------------------
* fetch a row into an array
* @param ORACLECURSOR $aCursor
function fetchArray($aCursor,$mode=
NULL,$debug=
FALSE) {
if ($debug) echo
"<p><b>DB_ORA::fetchArray($aCursor,$mode,...)</b></p>";
if (!$mode) $mode=
OCI_ASSOC+
OCI_RETURN_NULLS+
OCI_RETURN_LOBS;
return oci_fetch_array($aCursor, $mode);
if (OCIFetchInto($aCursor,$this->oraResults['CUR_'.
$aCursor], OCI_ASSOC+
OCI_RETURN_NULLS))
// ------------------------------------------
$this->oraResults['CUR_'.
$aCursor]['numRows'] =
@OCIFetchStatement($aCursor,$results);
if ($this->oraResults['CUR_'.
$aCursor]['numRows'] <
1) {
$this->oraResults['CUR_'.
$aCursor]['rows'] =
$results;
// ------------------------------------------
@OCIFreeStatement($aCursor);
###############################################
function insert($aQuery, $aTable=
"", $keyfld=
"",$debug=
FALSE) {
if ($debug) echo
"<p><b>DB_ORA::insert(...)</b> (".
get_class($this).
")</p>";
$aQuery .=
" RETURNING $keyfld INTO :newKey";
if ($debug) echo
"<blockquote><p>Query:<br />$aQuery</p></blockquote>";
if ($stmt =
OCIParse($this->dbConnId,$aQuery)) {
OCIBindByName($stmt,":newKey",&$newKey,32);
if (OCIExecute($stmt,OCI_DEFAULT)) {
if ($debug) echo
"<p><b>DB_ORA::executeCmd($aQuery,...)</b> (".
get_class($this).
")</p>";
if ($stmt =
OCIParse($this->dbConnId,$aQuery)) {
if (OCIExecute($stmt,OCI_DEFAULT)) {
if ($stmt =
OCIParse($this->dbConnId,$aQuery)) {
while(list
($key,$val) =
each($aBindArr)) {
OCIBindByName($stmt,":".
$key,$key,$val['SIZE'],$val['TYPE']);
OCIBindByName($stmt,":".
$key,$key,$val['SIZE']);
if (OCIExecute($stmt,OCI_DEFAULT)) {
while(list
($key,$val) =
each($aBindArr)) {
$aBindArr[$key] = $
{$key};
###############################################
$query =
"SELECT c.NAME FROM SYS.OBJ$ o, SYS.COL$ c WHERE o.NAME = '$aTable' AND o.OBJ# = c.OBJ#";
if ($cursor=
$this->query($query)) {
if ($numRows=
OCIFetchStatement($cursor,$result)) { /* rein compatibility */
// if ($_POST['REIN2_LOGIN'] == "pkrebs") $debug=TRUE;
if (!empty($_POST['REIN2_LOGIN'])) {
require_once $GLOBALS['PROJECT']['PATH'].
"rein1php/ora_connect.phpinc";
require_once $GLOBALS['PROJECT']['PATH'].
"rein1php/shop/six_func/cookie.inc";
require_once $GLOBALS['PROJECT']['PATH'].
"rein1php/shop/password.phpinc";
if (checkPasswd($ORADB, $_POST['REIN2_LOGIN'], $_POST['REIN2_PASSWORD'],$debug)) {
Set_AuthCookie($REIN2_SYS_USER['USR_LOGIN']);
require_once $GLOBALS['PROJECT']['PATH'].
"rein1php/convertclient.phpinc";
$cliId=
rein1_getClient($ORADB,$REIN2_SYS_USER['USR_LOGIN'],$debug);
include $GLOBALS['PROJECT']['PATH'].
"templates/system/loginform.phpinc";
while (list
($key,$val) =
each($result)) {
while (list
($key,$val) =
each($err))
echo
"\n<li>$key: $val</li>\n";
###############################################
if ($debug) echo
"<p><b>DB_ORA::getTableList($owner,...)</b></p>";
$query =
"SELECT TABLE_NAME FROM SYS.DBA_TABLES WHERE OWNER = '$owner'";
$query =
"SELECT OWNER || '.' || TABLE_NAME FROM SYS.DBA_TABLES";
if ($cursor =
$this->query($query)) {
$query =
"SELECT COLUMN_NAME,DATA_TYPE,NULLABLE,DATA_DEFAULT,DATA_LENGTH FROM DBA_TAB_COLUMNS WHERE OWNER='$owner' AND TABLE_NAME='$aTable'";
if ($cursor =
$this->query($query)) {
$retArr[$arr['COLUMN_NAME']][0] =
$arr['DATA_TYPE']; # DB TYPE
$retArr[$arr['COLUMN_NAME']][1] =
$arr['NULLABLE']; # NULL VALUE
$retArr[$arr['COLUMN_NAME']][2] =
""; # KEY
$retArr[$arr['COLUMN_NAME']][3] =
$arr['DATA_DEFAULT']; # DEFAULT VALUE
$retArr[$arr['COLUMN_NAME']][4] =
""; # FUNCTION
$retArr[$arr['COLUMN_NAME']][5] =
$arr['DATA_LENGTH']; # DATA_TYPE LENGTH
* removes /0 from $aValue
if ($debug) echo
"<p><b>DB_ORA::convertString($aValue,..)</b> (".
get_class($this).
")</p><blockquote><ul>";
for ($i=
0;$i <
strlen($aValue);$i++
) {
if ($debug) echo
"</li>$i: $char=" .
ord($char).
"</li>";
if (ord($char) >
0 &&
ord($char) <
255)
if ($debug) echo
"</ul><p>returns: $ret</p></blockqoute>";
Documentation generated on Thu, 08 Jan 2009 17:47:37 +0100 by phpDocumentor 1.4.0a2