Login Retreive lost passwordRegister
Search

Forum Index / General / Oracle database support

[ This topic is solved ]

  Joao Correa 18 December 08 / 15:07  
Changed at 19 December 08 / 17:24
Hi!

Is possible to add a database support for Oracle?

Like a file class.ORACLE.php?

Thanks!

  Johan Wiegel (Admin) 20 December 08 / 09:41  
Yes that is possible.
You just need to create the same functions as in for example class.MySQL.php

Of course it will take some testing etc.

If you have one, can you send it to us to include it ?

  Joao Correa 20 December 08 / 19:43  
Sure!

CLASS:

<?
class ORA {

    var 
$query;
    var 
$link;
    var 
$result;
    
    
/**
    * @return ORA
    * @desc Constructor of ORA class.
    */
    
function ORA(){
    }
    
/**
    * @return void
    * @desc Method of Server Connection and DB.
    */
   
function connect($db="XXX",$user="XXXX",$pass="XXX"){
       
             
$this->socket oci_connect($user,$pass,$db);
             if ( 
$this->socket == false ){
                echo 
oci_error($this->socket)."<BR>";
                echo 
"Fail";
                exit;
              }
      }
    
/**
    * @return Result
    * @param String $query
    * @desc Receive query SQL, execute and retuns, if error returs 0.
    */
    
function sql($query){
        
        
$this->connect();
        
$this->query $query;        
        if(
$this->result=oci_parse($this->socket,$this->query)){
            
oci_execute($this->result);
            
$this->disconnect();
            return 
$this->result;
        } else {
            die(
"<b>Error in SQL Query:</b><br>$query<br><br><b>ORACLE Returns: ".oci_error()."</b>");
            
$this->disconnect();
        }
        
    }
    
/**
    * @return oci_close
    * @desc Server Disconnect
    */
    
function disconnect(){
        return 
$this->CloseData = @oci_close($this->socket);
    }
}


?>



USAGE:
<?
include("conn.php");
$ORA = new ORA;    
$sql $ORA->sql("SELECT * FROM TABLE");

while(
$a oci_fetch_array($sql,OCI_BOTH)){
 
echo
"Fields from table";     
}
?>


Regards!

  Johan Wiegel (Admin) 20 December 08 / 19:53  
Changed at 20 December 08 / 20:00
It's a good start but we need more functions to include it in FH.

needed functions:

connect
close
query
getInsertId
result
getError
getErrorNo
recordCount
getRecord
getFieldNames
getTables
getNotNullFields
getFieldTypes
escapeString
getPrKeys
getUniqueFields

Is there an easy way to test with an Oracle database?
Since we don't have any experience using Oracle we would apriciate you making a complete class like class.MySQL.php in the yadal directory.

  Joao Correa 06 January 09 / 20:28  
Changed at 06 January 09 / 20:29
Hi Johan,

I need you help.

Look the code, the last query returns this:

SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner, cons.constraint_type FROM all_constraints cons, all_cons_columns cols WHERE cols.table_name = 'BOL_SISTEMAS' AND cons.constraint_name = cols.constraint_name AND cons.owner = cols.owner ORDER BY cols.table_name, cols.position; DESC BOL_SISTEMAS;DESC BOL_SISTEMAS;SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner, cons.constraint_type FROM all_constraints cons, all_cons_columns cols WHERE cols.table_name = 'BOL_SISTEMAS' AND cons.constraint_name = cols.constraint_name AND cons.owner = cols.owner ORDER BY cols.table_name, cols.position;

  Joao Correa 06 January 09 / 20:33  
i send a email to you.

  Johan Wiegel (Admin) 07 January 09 / 11:19  
Joao,

I did not receive any email yet??

  Johan Wiegel (Admin) 16 June 09 / 19:46  
since I didn't receive any response since january I will close the toppic

  Top


powered by PHP-GLOBE   © 2004 - 2012 FormHandler. All rights reserved.   -   Open source license