ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:database:oracle

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
v5:database:oracle [2016/01/13 01:53] – ↷ Page moved from database:oracle to v5:database:oracle mnewnhamv5:database:oracle [2023/01/25 04:40] (current) – [Auto-Increment Column] mnewnham
Line 13: Line 13:
 ^ADOdb V6|Yes| ^ADOdb V6|Yes|
 == Alternatives == == Alternatives ==
-**Alternative Drivers**\\ +[[v5:database:pdo#pdo_oci|PDO driver for Oracle]] 
-[[database:pdo#pdo_oci|PDO driver for Oracle]]\\ +== See Also == 
-[[database:ado|ADO driver for Oracle]]+[[v5:reference:connection:setconnectionparameter#oracle|setConnectionParameter()]]
 </WRAP> </WRAP>
  
 ** This is the preferred driver for connecting to Oracle databases ** ** This is the preferred driver for connecting to Oracle databases **
 Despite its name, this driver supports Oracle databases up to and including Oracle 11.  Despite its name, this driver supports Oracle databases up to and including Oracle 11. 
 +
 +This is currently the only supported driver when using PHP 7
 --------------------------------------- ---------------------------------------
 ===== Driver Specific Methods ===== ===== Driver Specific Methods =====
Line 27: Line 29:
 The following **non-portable** methods are available to this driver The following **non-portable** methods are available to this driver
 ^ Method                                              ^ Description                                ^ ^ Method                                              ^ Description                                ^
-| [[reference:oracle:bind|bind()]]                    | A fast way of updating records             | +| [[v5:database:oracle:bind|bind()]]                    | A fast way of updating records             | 
-| [[reference:oracle:ExecuteCursor|executeCursor()]]  | Returns a cursor to procedure as a handle +| [[v5:database:oracle:executecursor|executeCursor()]]  | Returns a cursor to procedure as a handle 
-{{tag>[oracle unix windows active]}}+{{tag>[oracle unix windows active tier1]}}
  
 ==== Connection Examples ==== ==== Connection Examples ====
Line 70: Line 72:
  
   $dsn = 'oci8://user:pwd@tnsname/?persist';  # persist is optional   $dsn = 'oci8://user:pwd@tnsname/?persist';  # persist is optional
-  $conn = ADONewConnection($dsn);  # no need for Connect/PConnect+  $conn = ADONewConnection($dsn);  # no need for connect/pConnect
  
   $dsn = 'oci8://user:pwd@host/sid';   $dsn = 'oci8://user:pwd@host/sid';
Line 87: Line 89:
      
 The default value for ''NLS_DATE_FORMAT'' is ''YYYY-MM-DD''. To include time as well, use ''RRRR-MM-DD HH24:MI:SS'' or set the value to empty to disable this action. The default value for ''NLS_DATE_FORMAT'' is ''YYYY-MM-DD''. To include time as well, use ''RRRR-MM-DD HH24:MI:SS'' or set the value to empty to disable this action.
 +----------------------------------
 +==== Auto-Increment Column ====
 +[[v5:dictionary:column_attributes#AUTO or AUTOINCREMENT|Auto-increment]] support for Oracle databases is implemented by creating an on-insert trigger that retrieves a sequence number from a sequence //**SEQ_ + table name **//. This is done by default.
  
-  +If you have long table names then the generated trigger name can exceed the maximum allowed length. To prevent this, use the class variable ''useCompactAutoIncrements''. This will change the trigger name to a generated CRC value of the name.  
 +=== Example using the table name "customer_delivery_address" === 
 +By default, the trigger name would be SEQ_CUSTOMER_DELIVERY_ADDRESS which exceeds the 16 character name for sequences. By setting ''$db->useCompactAutoIncrements=true'', the sequence name is changed to ''SEQ_401703491'' 
 + 
 +=== Accessing the trigger in your code === 
 +<code php> 
 + 
 +$db->useCompactAutoIncrements=true; 
 + 
 +$tab = 'customer_delivery_address'; 
 +$tab = sprintf('SEQ_%u',crc32(strtolower($tab))); 
 + 
 +print $tab; //prints SEQ_401703491 
 + 
 +</code> 
 + 
 +----------------------------------- 
 +==== Session Mode ==== 
 + 
 +From ADOdb **V5.23.0**, You can use external ''(OCI_CRED_EXT)'' or privileged (''OCI_SYSOPER or OCI_SYSDBA'') sessions via the [[v5:reference:connection:setconnectionparameter|setConnectionParameter()]] method, **prior** to establishing a connection. 
 + 
 +<code php> 
 + 
 +$db = ADONewConnection('oci8'); 
 +$db->setConnectionParameter('session_mode', OCI_CRED_EXT); 
 +$db->connect(false, 'scott', 'tiger', 'myTNS'); 
 + 
 +</code> 
 + 
 + 
 +----------------------------------------------
 ====== oci8po ====== ====== oci8po ======
 <WRAP right box round 300px> <WRAP right box round 300px>
Line 100: Line 135:
 ^ADOdb V6|Yes| ^ADOdb V6|Yes|
 </WRAP> </WRAP>
-This driver extends the oci8 driver and provides compatibility with other database drivers such as MySQL and SQL Server. Use this version of the driver if you are writing portable code. +This driver extends the oci8 driver and mostly provides compatibility with MySQL databases which use the ? placeholder for bind params.  
 + 
 +If you are migrating code or writing portable code, consider using the [[v5:reference:connection:param|param()]] command to write portable placeholders. 
 + 
 +A second difference to this driver is that it does not create a sequence to emulate auto-increment fields. You must provide the functionality yourself if you need it. 
 {{tag>[oracle unix windows active portable]}} {{tag>[oracle unix windows active portable]}}
 ------------------------------------ ------------------------------------
Line 115: Line 155:
 </WRAP> </WRAP>
 This driver provides an undocumented enhancement to the oci8 driver This driver provides an undocumented enhancement to the oci8 driver
 +
 +It adds a [[https://docs.oracle.com/cd/B12037_01/server.101/b10752/hintsref.htm#4942|FIRST_ROWS]] optimizer hint to the SQL statements executed with [[v5:reference:connection:selectlimit]]. 
 +Note that //FIRST_ROWS// has been deprecated in Oracle 9.2, and is retained for backwards compatibility.
 +
 {{tag>[oracle unix windows deprecated]}}  {{tag>[oracle unix windows deprecated]}} 
  
Line 122: Line 166:
 <WRAP right box round 300px> <WRAP right box round 300px>
 == Specification == == Specification ==
-^Driver Name|oci805cus|+^Driver Name|oci8quercus|
 ^Data Provider|oracle| ^Data Provider|oracle|
 ^Status|Inactive((This driver is obsolete is not actively supported or enhanced by ADOdb project members, but you can provide fixes and enhancements if you have the expertise))| ^Status|Inactive((This driver is obsolete is not actively supported or enhanced by ADOdb project members, but you can provide fixes and enhancements if you have the expertise))|
Line 130: Line 174:
 ^ADOdb V6|Yes| ^ADOdb V6|Yes|
 </WRAP> </WRAP>
-This driver provides an undocumented enhancement to the oci8 driver+This driver provides an undocumented enhancement to the oci8 driver. The differences in the driver relate solely to the use of cursors in stored procedures. This may be related to information in the function [[v5:database:oracle:executecursor|executeCursor]]  and the [[v5:userguide:oracle_tutorial|Oracle Tutorial]]. If you have the appropriate expertise and the time to investigate and explain these drivers, let us know.
 {{tag>[oracle unix windows deprecated]}}  {{tag>[oracle unix windows deprecated]}} 
  
Line 137: Line 181:
 ====== oracle ====== ====== oracle ======
 <WRAP info> <WRAP info>
-Support for oracle databases versions 7 and lower was removed in PHP version 5.1. In ADOdb version 6, the Oracle driver will be removed and the oci8 driver will become the oracle driver+Support for oracle databases versions 7 and lower was removed in PHP version 5.1. In ADOdb version 6, the Oracle driver will be removed
 </WRAP> </WRAP>
 <WRAP right box round 300px> <WRAP right box round 300px>
Line 149: Line 193:
 ^ADOdb V6|No| ^ADOdb V6|No|
 </WRAP> </WRAP>
-This driver provided support to oracle 7 and lower databases. The driver is obsolete, and not supported by PHP and will be removed in ADOdb version 6.0 The data provider name 'oracle' will be assigned to the oci8 driver. The oci8 driver will become a stub to provide backwards compatibility.+This driver provided support to oracle 7 and lower databases. The driver is obsolete, and not supported by PHP and will be removed in ADOdb version 6.0.
  
    
v5/database/oracle.1452646420.txt.gz · Last modified: 2017/04/21 11:24 (external edit)