summaryrefslogtreecommitdiff
path: root/drivers/adodb-oci8.inc.php
diff options
context:
space:
mode:
authorMark Newnham <mark@newnhams.com>2019-11-28 11:38:07 -0700
committerDamien Regad <dregad@mantisbt.org>2020-01-12 18:09:51 +0100
commit1d4de5ee7a72cff039308f33b8a4a34d92c9c4b4 (patch)
tree413b35afcaffacc073d7c4e6e975cdca20218659 /drivers/adodb-oci8.inc.php
parentdbff2a1eb4a6be34c03e380099d34b1f3889a409 (diff)
downloadadodb-1d4de5ee7a72cff039308f33b8a4a34d92c9c4b4.tar.gz
adodb-1d4de5ee7a72cff039308f33b8a4a34d92c9c4b4.tar.bz2
adodb-1d4de5ee7a72cff039308f33b8a4a34d92c9c4b4.zip
oci8: create compact trigger/sequence names
This enhancement provides a method of creating an emulated auto- increment column for a table with a name greater than 25 characters, built using createTableSql() and specifying an "AUTO" option on the required column. Instead of using the table name, a CRC32 value of the tablename is created and used for the name of the sequence and trigger, i.e. instead of a trigger called "TRIG_EMPLOYEES" for a table called "EMPLOYEES", it creates a trigger "TRIG_3129131776", and similarly, a trigger for a table named "EMPLOYEE_HOURLY_PAY_RATES" becomes "TRIG_3754194288". The name of the trigger and sequence can be easily obtained after the fact by finding the CRC32 value of the table name. The feature is provided with a compatibility flag that must be enabled. Existing configurations that already use this feature are unchanged. To activate, set the dictionary class variable `$dict->useCompactAutoIncrements = true` when building the table, and the connection class variable `$db->useCompactAutoIncrements = true` when using the table in ADOdb. The feature is global for the database and cannot be specified on a table level basis. Fixes #565
Diffstat (limited to 'drivers/adodb-oci8.inc.php')
-rw-r--r--drivers/adodb-oci8.inc.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/adodb-oci8.inc.php b/drivers/adodb-oci8.inc.php
index 2658a3c0..12422969 100644
--- a/drivers/adodb-oci8.inc.php
+++ b/drivers/adodb-oci8.inc.php
@@ -103,6 +103,23 @@ END;
// var $ansiOuter = true; // if oracle9
+ /*
+ * Legacy compatibility for sequence names for emulated auto-increments
+ */
+ public $useCompactAutoIncrements = false;
+
+ /*
+ * Defines the schema name for emulated auto-increment columns
+ */
+ public $schema = false;
+
+ /*
+ * Defines the prefix for emulated auto-increment columns
+ */
+ public $seqPrefix = 'SEQ_';
+
+
+
function __construct()
{
$this->_hasOciFetchStatement = ADODB_PHPVER >= 0x4200;
@@ -304,6 +321,43 @@ END;
{
return " NVL($field, $ifNull) "; // if Oracle
}
+
+ function _insertid($tabname,$column='')
+ {
+
+ if (!$this->seqField)
+ return false;
+
+
+ if ($this->schema)
+ {
+ $t = strpos($tabname,'.');
+ if ($t !== false)
+ $tab = substr($tabname,$t+1);
+ else
+ $tab = $tabname;
+
+ if ($this->useCompactAutoIncrements)
+ $tab = sprintf('%u',crc32(strtolower($tab)));
+
+ $seqname = $this->schema.'.'.$this->seqPrefix.$tab;
+ }
+ else
+ {
+ if ($this->useCompactAutoIncrements)
+ $tabname = sprintf('%u',crc32(strtolower($tabname)));
+
+ $seqname = $this->seqPrefix.$tabname;
+ }
+
+ if (strlen($seqname) > 30)
+ /*
+ * We cannot successfully identify the sequence
+ */
+ return false;
+
+ return $this->getOne("SELECT $seqname.currval FROM dual");
+ }
// format and return date string in database date format
function DBDate($d,$isfld=false)