"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/adodb/adodb/datadict/datadict-firebird.inc.php Source File", "datetime" => "Sat Dec 2 19:22:25 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>
00001 <?php 00002 00013 class ADODB2_firebird extends ADODB_DataDict { 00014 00015 var $databaseType = 'firebird'; 00016 var $seqField = false; 00017 var $seqPrefix = 'gen_'; 00018 var $blobSize = 40000; 00019 00020 function ActualType($meta) 00021 { 00022 switch($meta) { 00023 case 'C': return 'VARCHAR'; 00024 case 'XL': return 'VARCHAR(32000)'; 00025 case 'X': return 'VARCHAR(4000)'; 00026 00027 case 'C2': return 'VARCHAR'; // up to 32K 00028 case 'X2': return 'VARCHAR(4000)'; 00029 00030 case 'B': return 'BLOB'; 00031 00032 case 'D': return 'DATE'; 00033 case 'T': return 'TIMESTAMP'; 00034 00035 case 'L': return 'SMALLINT'; 00036 case 'I': return 'INTEGER'; 00037 case 'I1': return 'SMALLINT'; 00038 case 'I2': return 'SMALLINT'; 00039 case 'I4': return 'INTEGER'; 00040 case 'I8': return 'INTEGER'; 00041 00042 case 'F': return 'DOUBLE PRECISION'; 00043 case 'N': return 'DECIMAL'; 00044 default: 00045 return $meta; 00046 } 00047 } 00048 00049 function NameQuote($name = NULL) 00050 { 00051 if (!is_string($name)) { 00052 return FALSE; 00053 } 00054 00055 $name = trim($name); 00056 00057 if ( !is_object($this->connection) ) { 00058 return $name; 00059 } 00060 00061 $quote = $this->connection->nameQuote; 00062 00063 // if name is of the form `name`, quote it 00064 if ( preg_match('/^`(.+)`$/', $name, $matches) ) { 00065 return $quote . $matches[1] . $quote; 00066 } 00067 00068 // if name contains special characters, quote it 00069 if ( !preg_match('/^[' . $this->nameRegex . ']+$/', $name) ) { 00070 return $quote . $name . $quote; 00071 } 00072 00073 return $quote . $name . $quote; 00074 } 00075 00076 function CreateDatabase($dbname, $options=false) 00077 { 00078 $options = $this->_Options($options); 00079 $sql = array(); 00080 00081 $sql[] = "DECLARE EXTERNAL FUNCTION LOWER CSTRING(80) RETURNS CSTRING(80) FREE_IT ENTRY_POINT 'IB_UDF_lower' MODULE_NAME 'ib_udf'"; 00082 00083 return $sql; 00084 } 00085 00086 function _DropAutoIncrement($t) 00087 { 00088 if (strpos($t,'.') !== false) { 00089 $tarr = explode('.',$t); 00090 return 'DROP GENERATOR '.$tarr[0].'."gen_'.$tarr[1].'"'; 00091 } 00092 return 'DROP GENERATOR "GEN_'.$t; 00093 } 00094 00095 00096 function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned) 00097 { 00098 $suffix = ''; 00099 00100 if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; 00101 if ($fnotnull) $suffix .= ' NOT NULL'; 00102 if ($fautoinc) $this->seqField = $fname; 00103 if ($fconstraint) $suffix .= ' '.$fconstraint; 00104 00105 return $suffix; 00106 } 00107 00108 /* 00109 CREATE or replace TRIGGER jaddress_insert 00110 before insert on jaddress 00111 for each row 00112 begin 00113 IF ( NEW."seqField" IS NULL OR NEW."seqField" = 0 ) THEN 00114 NEW."seqField" = GEN_ID("GEN_tabname", 1); 00115 end; 00116 */ 00117 function _Triggers($tabname,$tableoptions) 00118 { 00119 if (!$this->seqField) return array(); 00120 00121 $tab1 = preg_replace( '/"/', '', $tabname ); 00122 if ($this->schema) { 00123 $t = strpos($tab1,'.'); 00124 if ($t !== false) $tab = substr($tab1,$t+1); 00125 else $tab = $tab1; 00126 $seqField = $this->seqField; 00127 $seqname = $this->schema.'.'.$this->seqPrefix.$tab; 00128 $trigname = $this->schema.'.trig_'.$this->seqPrefix.$tab; 00129 } else { 00130 $seqField = $this->seqField; 00131 $seqname = $this->seqPrefix.$tab1; 00132 $trigname = 'trig_'.$seqname; 00133 } 00134 if (isset($tableoptions['REPLACE'])) 00135 { $sql[] = "DROP GENERATOR \"$seqname\""; 00136 $sql[] = "CREATE GENERATOR \"$seqname\""; 00137 $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"; 00138 } 00139 else 00140 { $sql[] = "CREATE GENERATOR \"$seqname\""; 00141 $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"; 00142 } 00143 00144 $this->seqField = false; 00145 return $sql; 00146 } 00147 00148 } 00149 00150 00151 ?>