From 8df3db566a3a937b45ebf11adb90d265e6f5e2d4 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sun, 17 Nov 2019 20:45:02 +0100 Subject: initial checking of customized version 1.0rc9 --- .../adodb-php/datadict/datadict-firebird.inc.php | 151 +++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 vendor/adodb/adodb-php/datadict/datadict-firebird.inc.php (limited to 'vendor/adodb/adodb-php/datadict/datadict-firebird.inc.php') diff --git a/vendor/adodb/adodb-php/datadict/datadict-firebird.inc.php b/vendor/adodb/adodb-php/datadict/datadict-firebird.inc.php new file mode 100644 index 0000000..cffcca1 --- /dev/null +++ b/vendor/adodb/adodb-php/datadict/datadict-firebird.inc.php @@ -0,0 +1,151 @@ +connection) ) { + return $name; + } + + $quote = $this->connection->nameQuote; + + // if name is of the form `name`, quote it + if ( preg_match('/^`(.+)`$/', $name, $matches) ) { + return $quote . $matches[1] . $quote; + } + + // if name contains special characters, quote it + if ( !preg_match('/^[' . $this->nameRegex . ']+$/', $name) ) { + return $quote . $name . $quote; + } + + return $quote . $name . $quote; + } + + function CreateDatabase($dbname, $options=false) + { + $options = $this->_Options($options); + $sql = array(); + + $sql[] = "DECLARE EXTERNAL FUNCTION LOWER CSTRING(80) RETURNS CSTRING(80) FREE_IT ENTRY_POINT 'IB_UDF_lower' MODULE_NAME 'ib_udf'"; + + return $sql; + } + + function _DropAutoIncrement($t) + { + if (strpos($t,'.') !== false) { + $tarr = explode('.',$t); + return 'DROP GENERATOR '.$tarr[0].'."gen_'.$tarr[1].'"'; + } + return 'DROP GENERATOR "GEN_'.$t; + } + + + function _CreateSuffix($fname,&$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned) + { + $suffix = ''; + + if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fnotnull) $suffix .= ' NOT NULL'; + if ($fautoinc) $this->seqField = $fname; + if ($fconstraint) $suffix .= ' '.$fconstraint; + + return $suffix; + } + +/* +CREATE or replace TRIGGER jaddress_insert +before insert on jaddress +for each row +begin +IF ( NEW."seqField" IS NULL OR NEW."seqField" = 0 ) THEN + NEW."seqField" = GEN_ID("GEN_tabname", 1); +end; +*/ + function _Triggers($tabname,$tableoptions) + { + if (!$this->seqField) return array(); + + $tab1 = preg_replace( '/"/', '', $tabname ); + if ($this->schema) { + $t = strpos($tab1,'.'); + if ($t !== false) $tab = substr($tab1,$t+1); + else $tab = $tab1; + $seqField = $this->seqField; + $seqname = $this->schema.'.'.$this->seqPrefix.$tab; + $trigname = $this->schema.'.trig_'.$this->seqPrefix.$tab; + } else { + $seqField = $this->seqField; + $seqname = $this->seqPrefix.$tab1; + $trigname = 'trig_'.$seqname; + } + if (isset($tableoptions['REPLACE'])) + { $sql[] = "DROP GENERATOR \"$seqname\""; + $sql[] = "CREATE GENERATOR \"$seqname\""; + $sql[] = "ALTER TRIGGER \"$trigname\" BEFORE INSERT OR UPDATE AS BEGIN IF ( NEW.$seqField IS NULL OR NEW.$seqField = 0 ) THEN NEW.$seqField = GEN_ID(\"$seqname\", 1); END"; + } + else + { $sql[] = "CREATE GENERATOR \"$seqname\""; + $sql[] = "CREATE TRIGGER \"$trigname\" FOR $tabname BEFORE INSERT OR UPDATE AS BEGIN IF ( NEW.$seqField IS NULL OR NEW.$seqField = 0 ) THEN NEW.$seqField = GEN_ID(\"$seqname\", 1); END"; + } + + $this->seqField = false; + return $sql; + } + +} -- cgit v1.2.3-54-g00ecf