Documentation TYPO3 par Ameos

datadict-sybase.inc.php

00001 <?php
00002 
00013 // security - hide paths
00014 if (!defined('ADODB_DIR')) die();
00015 
00016 class ADODB2_sybase extends ADODB_DataDict {
00017         var $databaseType = 'sybase';
00018         
00019         var $dropIndex = 'DROP INDEX %2$s.%1$s';
00020         
00021         function MetaType($t,$len=-1,$fieldobj=false)
00022         {
00023                 if (is_object($t)) {
00024                         $fieldobj = $t;
00025                         $t = $fieldobj->type;
00026                         $len = $fieldobj->max_length;
00027                 }
00028                 
00029                 $len = -1; // mysql max_length is not accurate
00030                 switch (strtoupper($t)) {
00031 
00032                 case 'INT': 
00033                 case 'INTEGER': return  'I';
00034                 case 'BIT':
00035                 case 'TINYINT': return  'I1';
00036                 case 'SMALLINT': return 'I2';
00037                 case 'BIGINT':  return  'I8';
00038                 
00039                 case 'REAL':
00040                 case 'FLOAT': return 'F';
00041                 default: return parent::MetaType($t,$len,$fieldobj);
00042                 }
00043         }
00044         
00045         function ActualType($meta)
00046         {
00047                 switch(strtoupper($meta)) {
00048                 case 'C': return 'VARCHAR';
00049                 case 'XL':
00050                 case 'X': return 'TEXT';
00051                 
00052                 case 'C2': return 'NVARCHAR';
00053                 case 'X2': return 'NTEXT';
00054                 
00055                 case 'B': return 'IMAGE';
00056                         
00057                 case 'D': return 'DATETIME';
00058                 case 'T': return 'DATETIME';
00059                 case 'L': return 'BIT';
00060                 
00061                 case 'I': return 'INT'; 
00062                 case 'I1': return 'TINYINT';
00063                 case 'I2': return 'SMALLINT';
00064                 case 'I4': return 'INT';
00065                 case 'I8': return 'BIGINT';
00066                 
00067                 case 'F': return 'REAL';
00068                 case 'N': return 'NUMERIC';
00069                 default:
00070                         return $meta;
00071                 }
00072         }
00073         
00074         
00075         function AddColumnSQL($tabname, $flds)
00076         {
00077                 $tabname = $this->TableName ($tabname);
00078                 $f = array();
00079                 list($lines,$pkey) = $this->_GenFields($flds);
00080                 $s = "ALTER TABLE $tabname $this->addCol";
00081                 foreach($lines as $v) {
00082                         $f[] = "\n $v";
00083                 }
00084                 $s .= implode(', ',$f);
00085                 $sql[] = $s;
00086                 return $sql;
00087         }
00088         
00089         function AlterColumnSQL($tabname, $flds)
00090         {
00091                 $tabname = $this->TableName ($tabname);
00092                 $sql = array();
00093                 list($lines,$pkey) = $this->_GenFields($flds);
00094                 foreach($lines as $v) {
00095                         $sql[] = "ALTER TABLE $tabname $this->alterCol $v";
00096                 }
00097 
00098                 return $sql;
00099         }
00100         
00101         function DropColumnSQL($tabname, $flds)
00102         {
00103                 $tabname = $this->TableName($tabname);
00104                 if (!is_array($flds)) $flds = explode(',',$flds);
00105                 $f = array();
00106                 $s = "ALTER TABLE $tabname";
00107                 foreach($flds as $v) {
00108                         $f[] = "\n$this->dropCol ".$this->NameQuote($v);
00109                 }
00110                 $s .= implode(', ',$f);
00111                 $sql[] = $s;
00112                 return $sql;
00113         }
00114         
00115         // return string must begin with space
00116         function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint)
00117         {       
00118                 $suffix = '';
00119                 if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
00120                 if ($fautoinc) $suffix .= ' DEFAULT AUTOINCREMENT';
00121                 if ($fnotnull) $suffix .= ' NOT NULL';
00122                 else if ($suffix == '') $suffix .= ' NULL';
00123                 if ($fconstraint) $suffix .= ' '.$fconstraint;
00124                 return $suffix;
00125         }
00126         
00127         /*
00128 CREATE TABLE 
00129     [ database_name.[ owner ] . | owner. ] table_name 
00130     ( { < column_definition > 
00131         | column_name AS computed_column_expression 
00132         | < table_constraint > ::= [ CONSTRAINT constraint_name ] }
00133 
00134             | [ { PRIMARY KEY | UNIQUE } [ ,...n ] 
00135     ) 
00136 
00137 [ ON { filegroup | DEFAULT } ] 
00138 [ TEXTIMAGE_ON { filegroup | DEFAULT } ] 
00139 
00140 < column_definition > ::= { column_name data_type } 
00141     [ COLLATE < collation_name > ] 
00142     [ [ DEFAULT constant_expression ] 
00143         | [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
00144     ] 
00145     [ ROWGUIDCOL] 
00146     [ < column_constraint > ] [ ...n ] 
00147 
00148 < column_constraint > ::= [ CONSTRAINT constraint_name ] 
00149     { [ NULL | NOT NULL ] 
00150         | [ { PRIMARY KEY | UNIQUE } 
00151             [ CLUSTERED | NONCLUSTERED ] 
00152             [ WITH FILLFACTOR = fillfactor ] 
00153             [ON {filegroup | DEFAULT} ] ] 
00154         ] 
00155         | [ [ FOREIGN KEY ] 
00156             REFERENCES ref_table [ ( ref_column ) ] 
00157             [ ON DELETE { CASCADE | NO ACTION } ] 
00158             [ ON UPDATE { CASCADE | NO ACTION } ] 
00159             [ NOT FOR REPLICATION ] 
00160         ] 
00161         | CHECK [ NOT FOR REPLICATION ] 
00162         ( logical_expression ) 
00163     } 
00164 
00165 < table_constraint > ::= [ CONSTRAINT constraint_name ] 
00166     { [ { PRIMARY KEY | UNIQUE } 
00167         [ CLUSTERED | NONCLUSTERED ] 
00168         { ( column [ ASC | DESC ] [ ,...n ] ) } 
00169         [ WITH FILLFACTOR = fillfactor ] 
00170         [ ON { filegroup | DEFAULT } ] 
00171     ] 
00172     | FOREIGN KEY 
00173         [ ( column [ ,...n ] ) ] 
00174         REFERENCES ref_table [ ( ref_column [ ,...n ] ) ] 
00175         [ ON DELETE { CASCADE | NO ACTION } ] 
00176         [ ON UPDATE { CASCADE | NO ACTION } ] 
00177         [ NOT FOR REPLICATION ] 
00178     | CHECK [ NOT FOR REPLICATION ] 
00179         ( search_conditions ) 
00180     } 
00181 
00182 
00183         */
00184         
00185         /*
00186         CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name 
00187     ON { table | view } ( column [ ASC | DESC ] [ ,...n ] ) 
00188                 [ WITH < index_option > [ ,...n] ] 
00189                 [ ON filegroup ]
00190                 < index_option > :: = 
00191                     { PAD_INDEX | 
00192                         FILLFACTOR = fillfactor | 
00193                         IGNORE_DUP_KEY | 
00194                         DROP_EXISTING | 
00195                     STATISTICS_NORECOMPUTE | 
00196                     SORT_IN_TEMPDB  
00197                 }
00198 */
00199         function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
00200         {
00201                 $sql = array();
00202                 
00203                 if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
00204                         $sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
00205                         if ( isset($idxoptions['DROP']) )
00206                                 return $sql;
00207                 }
00208                 
00209                 if ( empty ($flds) ) {
00210                         return $sql;
00211                 }
00212                 
00213                 $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
00214                 $clustered = isset($idxoptions['CLUSTERED']) ? ' CLUSTERED' : '';
00215                 
00216                 if ( is_array($flds) )
00217                         $flds = implode(', ',$flds);
00218                 $s = 'CREATE' . $unique . $clustered . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')';
00219                 
00220                 if ( isset($idxoptions[$this->upperName]) )
00221                         $s .= $idxoptions[$this->upperName];
00222 
00223                 $sql[] = $s;
00224                 
00225                 return $sql;
00226         }
00227 }
00228 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6