tbrehm
2012-04-23 d02193c14c33dd12edb14f000b1c4eb6b7c3f070
commit | author | age
b5a2f8 1 <?php
T 2 /*
d02193 3 Copyright (c) 2007-2012, Till Brehm, projektfarm Gmbh, ISPConfig UG
b5a2f8 4 All rights reserved.
T 5
6 Redistribution and use in source and binary forms, with or without modification,
7 are permitted provided that the following conditions are met:
8
9     * Redistributions of source code must retain the above copyright notice,
10       this list of conditions and the following disclaimer.
11     * Redistributions in binary form must reproduce the above copyright notice,
12       this list of conditions and the following disclaimer in the documentation
13       and/or other materials provided with the distribution.
14     * Neither the name of ISPConfig nor the names of its contributors
15       may be used to endorse or promote products derived from this software without
16       specific prior written permission.
17
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
436ed8 30 class db {
00dfba 31     private $dbHost = '';           // hostname of the MySQL server
R 32     private $dbName = '';           // logical database name on that server
33     private $dbUser = '';           // database authorized user
34     private $dbPass = '';           // user's password
12fcb2 35     private $dbCharset = '';       // what charset comes and goes to mysql: utf8 / latin1
c84a6d 36     private $dbNewLink = false;    // Return a new linkID when connect is called again
T 37     private $dbClientFlags = 0;    // MySQL Client falgs
00dfba 38     private $linkId = 0;           // last result of mysql_connect()
R 39     private $queryId = 0;           // last result of mysql_query()
40     private $record    = array();       // last record fetched
12fcb2 41     private $autoCommit = 1;        // Autocommit Transactions
00dfba 42     private $currentRow;           // current row number
R 43     private $errorNumber = 0;       // last error number
44     public $errorMessage = '';       // last error message
45     private $errorLocation = '';   // last error location
010876 46     public $show_error_messages = false;
b5a2f8 47
e6c1c4 48     public function __construct()
P 49     {
50         global $conf;
51         $this->dbHost = $conf['db_host'];
52         $this->dbName = $conf['db_database'];
53         $this->dbUser = $conf['db_user'];
54         $this->dbPass = $conf['db_password'];
00dfba 55         $this->dbCharset = $conf['db_charset'];
c84a6d 56         $this->dbNewLink = $conf['db_new_link'];
T 57         $this->dbClientFlags = $conf['db_client_flags'];
e6c1c4 58         //$this->connect();
P 59     }
60
61     /**  Error handler */
62     public function updateError($location)
63     {
64         $this->errorNumber = mysql_errno();
65         $this->errorMessage = mysql_error();
66         $this->errorLocation = $location;
67         if($this->errorNumber && $this->show_error_messages){
68             echo('<br /><b>'.$this->errorLocation.'</b><br />'.$this->errorMessage);
69             flush();
b5a2f8 70         }
e6c1c4 71     }
b5a2f8 72
e6c1c4 73     public function connect()
12fcb2 74     {
e6c1c4 75         if($this->linkId == 0){
c84a6d 76             $this->linkId = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbNewLink, $this->dbClientFlags);
e6c1c4 77             if(!$this->linkId){
P 78                 $this->updateError('DB::connect()<br />mysql_connect');
b5a2f8 79                 return false;
T 80             }
00dfba 81             $this->queryId = @mysql_query('SET NAMES '.$this->dbCharset, $this->linkId);
e65b04 82             $this->queryId = @mysql_query("SET character_set_results = '".$this->dbCharset."', character_set_client = '".$this->dbCharset."', character_set_connection = '".$this->dbCharset."', character_set_database = '".$this->dbCharset."', character_set_server = '".$this->dbCharset."'", $this->linkId);
b5a2f8 83         }
e6c1c4 84         return true;
P 85     }
b5a2f8 86
e6c1c4 87     public function query($queryString)
12fcb2 88     {
e6c1c4 89         if(!$this->connect()){
P 90             return false;
b5a2f8 91         }
e6c1c4 92         if(!mysql_select_db($this->dbName, $this->linkId)){
P 93             $this->updateError('DB::connect()<br />mysql_select_db');
94             return false;
95         }
96         $this->queryId = @mysql_query($queryString, $this->linkId);
97         $this->updateError('DB::query('.$queryString.')<br />mysql_query');
98         if(!$this->queryId){
99             return false;
100         }
101         $this->currentRow = 0;
102         return $this->queryId;
103     }
b5a2f8 104
e6c1c4 105     /** Returns all records as an array */
P 106     public function queryAllRecords($queryString)
12fcb2 107     {
e6c1c4 108         if(!$this->query($queryString)){
P 109             return false;
b5a2f8 110         }
e6c1c4 111         $ret = array();
P 112         while($line = $this->nextRecord()){
113             $ret[] = $line;
114         }
115         return $ret;
116     }
b5a2f8 117
e6c1c4 118     /** Returns one row as an array */
P 119     public function queryOneRecord($queryString)
12fcb2 120     {
e6c1c4 121         if(!$this->query($queryString) || $this->numRows() == 0){
P 122             return false;
b5a2f8 123         }
e6c1c4 124         return $this->nextRecord();
P 125     }
b5a2f8 126
e6c1c4 127     /** Returns the next record as an array */
P 128     public function nextRecord()
12fcb2 129     {
J 130     $this->record = mysql_fetch_assoc($this->queryId);
e6c1c4 131         $this->updateError('DB::nextRecord()<br />mysql_fetch_array');
P 132         if(!$this->record || !is_array($this->record)){
133             return false;
b5a2f8 134         }
e6c1c4 135         $this->currentRow++;
P 136         return $this->record;
137     }
138
139     /** Returns the number of rows returned by the last select query */
140     public function numRows()
141     {
142         return mysql_num_rows($this->queryId);
143     }
144
145     public function affectedRows()
146     {
147         return mysql_affected_rows($this->linkId);
148     }
b5a2f8 149         
e6c1c4 150     /** Returns the last mySQL insert_id() */
P 151     public function insertID()
12fcb2 152     {
e6c1c4 153         return mysql_insert_id($this->linkId);
P 154     }
b5a2f8 155         
e6c1c4 156     /** Checks a variable - Depreciated, use quote() */
P 157     public function check($formfield)
158     {
159         return $this->quote($formfield);
160     }
b5a2f8 161         
8500be 162     /** Escapes quotes in variable. mysql_real_escape_string() */
e6c1c4 163     public function quote($formfield)
8500be 164     {    
T 165         if(!$this->connect()){
166             $this->updateError('WARNING: mysql_connect: Used addslashes instead of mysql_real_escape_string');
167             return addslashes($formfield);
168         }
169         return mysql_real_escape_string($formfield, $this->linkId);
e6c1c4 170     }
b5a2f8 171         
e6c1c4 172     /** Unquotes a variable, strip_slashes() */
P 173     public function unquote($formfield)
174     {
175         return stripslashes($formfield);
176     }
b5a2f8 177         
e6c1c4 178     public function toLower($record)
P 179     {
180         if(is_array($record)){
181             foreach($record as $key => $val) {
182                 $key = strtolower($key);
183                 $out[$key] = $val;
b5a2f8 184             }
T 185         }
e6c1c4 186         return $out;
P 187     }
b5a2f8 188        
430a0f 189     // deprecated
T 190     /*
e6c1c4 191     public function insert($tablename, $form, $debug = 0)
P 192     {
193         if(is_array($form)){
194             foreach($form as $key => $value){
195                 $sql_key .= "$key, ";
196                 $sql_value .= "'".$this->check($value)."', ";
197             }
198             $sql_key = substr($sql_key,0,strlen($sql_key) - 2);
199             $sql_value = substr($sql_value,0,strlen($sql_value) - 2);
200             $sql = "INSERT INTO $tablename (".$sql_key.') VALUES ('.$sql_value.')';
201             //TODO: where has $debug come from !???
202             if($debug == 1){ echo "SQL-Statement: $sql<br><br>"; }
203             $this->query($sql);
204             if($debug == 1){ echo 'mySQL Error Message: '.$this->errorMessage; }
205         }
206     }
430a0f 207     
T 208     // Deprecated
e6c1c4 209     public function update($tablename, $form, $bedingung, $debug = 0)
P 210     {
211         if(is_array($form)){
212             foreach($form as $key => $value){
213                 $insql .= "$key = '".$this->check($value)."', ";
214             }
215             $insql = substr($insql, 0, strlen($insql) - 2);
216             $sql = "UPDATE $tablename SET " . $insql . " WHERE $bedingung";
217             if($debug == 1){ echo "SQL-Statement: $sql<br><br>"; }
218             $this->query($sql);
219             if($debug == 1){ echo 'mySQL Error Message: '.$this->errorMessage; }
220         }
221     }
430a0f 222     */
12fcb2 223
74829e 224     public function diffrec($record_old, $record_new) {
958705 225         $diffrec_full = array();
T 226         $diff_num = 0;
227
228         if(is_array($record_old) && count($record_old) > 0) {
229             foreach($record_old as $key => $val) {
74829e 230                 // if(!isset($record_new[$key]) || $record_new[$key] != $val) {
T 231                 if($record_new[$key] != $val) {
958705 232                     // Record has changed
T 233                     $diffrec_full['old'][$key] = $val;
234                     $diffrec_full['new'][$key] = $record_new[$key];
235                     $diff_num++;
236                 } else {
237                     $diffrec_full['old'][$key] = $val;
238                     $diffrec_full['new'][$key] = $val;
239                 }
240             }
241         } elseif(is_array($record_new)) {
242             foreach($record_new as $key => $val) {
8065e0 243                 if(isset($record_new[$key]) && @$record_old[$key] != $val) {
958705 244                     // Record has changed
T 245                     $diffrec_full['new'][$key] = $val;
8065e0 246                     $diffrec_full['old'][$key] = @$record_old[$key];
958705 247                     $diff_num++;
T 248                 } else {
249                     $diffrec_full['new'][$key] = $val;
250                     $diffrec_full['old'][$key] = $val;
251                 }
252             }
253         }
254         
74829e 255         return array('diff_num' => $diff_num, 'diff_rec' => $diffrec_full);
T 256         
257     }
258     
259     //** Function to fill the datalog with a full differential record.
d02193 260     public function datalogSave($db_table, $action, $primary_field, $primary_id, $record_old, $record_new, $force_update = false) {
74829e 261         global $app,$conf;
T 262
d02193 263         //* Insert backticks only for incomplete table names.
74829e 264         if(stristr($db_table,'.')) {
T 265             $escape = '';
266         } else {
267             $escape = '`';
268         }
269         
d02193 270         if($force_update == true) {
T 271             //* We force a update even if no record has changed
272             $diffrec_full = array('new' => $record_new, 'old' => $record_old);
273             $diff_num = count($record_new);
274         } else {
275             //* get the difference record between old and new record
276             $tmp = $this->diffrec($record_old, $record_new);
277             $diffrec_full = $tmp['diff_rec'];
278             $diff_num = $tmp['diff_num'];
279             unset($tmp);
280         }
281         
282         //* Insert the server_id, if the record has a server_id
12fcb2 283         $server_id = (isset($record_old['server_id']) && $record_old['server_id'] > 0)?$record_old['server_id']:0;
J 284         if(isset($record_new['server_id'])) $server_id = $record_new['server_id'];
430a0f 285         
958705 286
T 287         if($diff_num > 0) {
288             $diffstr = $app->db->quote(serialize($diffrec_full));
12fcb2 289             $username = $app->db->quote($_SESSION['s']['user']['username']);
J 290             $dbidx = $primary_field.':'.$primary_id;
958705 291                         
T 292             if($action == 'INSERT') $action = 'i';
293             if($action == 'UPDATE') $action = 'u';
294             if($action == 'DELETE') $action = 'd';
295             $sql = "INSERT INTO sys_datalog (dbtable,dbidx,server_id,action,tstamp,user,data) VALUES ('".$db_table."','$dbidx','$server_id','$action','".time()."','$username','$diffstr')";
296             $app->db->query($sql);
297         }
298
299         return true;
300     }
301     
eea5cf 302     //** Inserts a record and saves the changes into the datalog
430a0f 303     public function datalogInsert($tablename, $insert_data, $index_field) {
T 304         global $app;
305         
471560 306         if(is_array($insert_data)) {
T 307             $key_str = '';
308             $val_str = '';
309             foreach($insert_data as $key => $val) {
310                 $key_str .= "`".$key ."`,";
311                 $val_str .= "'".$this->quote($val)."',";
312             }
313             $insert_data_str = '('.$key_str.') VALUES ('.$val_str.')';
314         } else {
315             $insert_data_str = $insert_data;
316         }
317         
430a0f 318         $old_rec = array();
471560 319         $this->query("INSERT INTO $tablename $insert_data_str");
430a0f 320         $index_value = $this->insertID();
T 321         $new_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'");
322         $this->datalogSave($tablename, 'INSERT', $index_field, $index_value, $old_rec, $new_rec);
323         
13d323 324         return $index_value;
430a0f 325     }
T 326     
327     //** Updates a record and saves the changes into the datalog
fddedd 328     public function datalogUpdate($tablename, $update_data, $index_field, $index_value, $force_update = false) {
958705 329         global $app;
T 330         
d02193 331         $old_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'");
471560 332         
T 333         if(is_array($update_data)) {
334             $update_data_str = '';
335             foreach($update_data as $key => $val) {
336                 $update_data_str .= "`".$key ."` = '".$this->quote($val)."',";
337             }
338         } else {
339             $update_data_str = $update_data;
340         }
341         
342         $this->query("UPDATE $tablename SET $update_data_str WHERE $index_field = '$index_value'");
958705 343         $new_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'");
d02193 344         $this->datalogSave($tablename, 'UPDATE', $index_field, $index_value, $old_rec, $new_rec, $force_update);
958705 345         
T 346         return true;
347     }
430a0f 348     
T 349     //** Deletes a record and saves the changes into the datalog
350     public function datalogDelete($tablename, $index_field, $index_value) {
351         global $app;
352         
353         $old_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'");
354         $this->query("DELETE FROM $tablename WHERE $index_field = '$index_value'");
355         $new_rec = array();
356         $this->datalogSave($tablename, 'DELETE', $index_field, $index_value, $old_rec, $new_rec);
357         
358         return true;
359     }
12fcb2 360
J 361
b5a2f8 362        
e6c1c4 363     public function closeConn()
P 364     {
55da90 365         if($this->linkId)
B 366         {
367             mysql_close($this->linkId);
368             return true;
369         } else { return false; }
e6c1c4 370     }
12fcb2 371     
55da90 372     public function freeResult($query) 
e6c1c4 373     {
55da90 374         if(mysql_free_result($query))
B 375         {
376             return true;
377         } else {
378             return false;
379         }
e6c1c4 380     }
430a0f 381     
T 382     /*
e6c1c4 383     public function delete()
P 384     {
385     }
430a0f 386     */
T 387     
388     /*
e6c1c4 389     public function Transaction($action)
P 390     {
391         //action = begin, commit oder rollback
392     }
430a0f 393     */
e6c1c4 394     
P 395     /** Creates a database table with the following format for the $columns array   
396     * <code>
397     * $columns = array(action =>   add | alter | drop
398     *                  name =>     Spaltenname
399     *                  name_new => neuer Spaltenname, nur bei 'alter' belegt
400     *                  type =>     42go-Meta-Type: int16, int32, int64, double, char, varchar, text, blob
401     *                  typeValue => Wert z.B. bei Varchar
402     *                  defaultValue =>  Default Wert
403     *                  notNull =>   true | false
404     *                  autoInc =>   true | false
405     *                  option =>   unique | primary | index)
406     * </code>   
407     */
430a0f 408     
T 409     
e6c1c4 410     public function createTable($table_name, $columns)
P 411     {
412         $index = '';
413         $sql = "CREATE TABLE $table_name (";
414         foreach($columns as $col){
415             $sql .= $col['name'].' '.$this->mapType($col['type'], $col['typeValue']).' ';
416             //* Set default value
010876 417             if(isset($col['defaultValue']) && $col['defaultValue'] != '') {
e6c1c4 418                 if($col['defaultValue'] == 'NULL' or $col['defaultValue'] == 'NOT NULL') {
P 419                     $sql .= 'DEFAULT '.$col['defaultValue'].' ';
420                 } else {
421                     $sql .= "DEFAULT '".$col['defaultValue']."' ";
422                 }
423             } elseif($col['defaultValue'] != false) {
424                 $sql .= "DEFAULT '' ";
425             }
010876 426             if(isset($col['defaultValue']) && $col['defaultValue'] != 'NULL' && $col['defaultValue'] != 'NOT NULL') {
e6c1c4 427                 if($col['notNull'] == true) {
P 428                     $sql .= 'NOT NULL ';
429                 } else {
430                     $sql .= 'NULL ';
431                 }
432             }
010876 433             if(isset($col['autoInc']) && $col['autoInc'] == true){ $sql .= 'auto_increment '; }
e6c1c4 434             $sql.= ',';
P 435             //* Index Definitions
010876 436             if(isset($col['option']) && $col['option'] == 'primary'){ $index .= 'PRIMARY KEY ('.$col['name'].'),'; }
T 437             if(isset($col['option']) && $col['option'] == 'index'){   $index .= 'INDEX ('.$col['name'].'),'; }
438             if(isset($col['option']) && $col['option'] == 'unique'){  $index .= 'UNIQUE ('.$col['name'].'),'; }
12fcb2 439        }
b5a2f8 440        $sql .= $index;
T 441        $sql = substr($sql,0,-1);
12fcb2 442        $sql .= ')';
b5a2f8 443        $this->query($sql);
T 444        return true;
e6c1c4 445     }
b5a2f8 446        
e6c1c4 447     /** Changes a table definition. The format for the $columns array is 
P 448     * <code>
449     * $columns = array(action =>   add | alter | drop
450     *                  name =>     Spaltenname
451     *                 name_new => neuer Spaltenname, nur bei 'alter' belegt
452     *                 type =>     42go-Meta-Type: int16, int32, int64, double, char, varchar, text, blob
453     *                 typeValue => Wert z.B. bei Varchar
454     *                 defaultValue =>  Default Wert
455     *                 notNull =>   true | false
456     *                 autoInc =>   true | false
457     *                 option =>   unique | primary | index)
458     */
459     public function alterTable($table_name,$columns)
460     {
12fcb2 461        $index = '';
J 462        $sql = "ALTER TABLE $table_name ";
463        foreach($columns as $col){
e6c1c4 464             if($col['action'] == 'add'){
12fcb2 465                 $sql .= 'ADD '.$col['name'].' '.$this->mapType($col['type'],$col['typeValue']).' ';
e6c1c4 466             }elseif($col['action'] == 'alter') {
P 467                 $sql .= 'CHANGE '.$col['name'].' '.$col['name_new'].' '.$this->mapType($col['type'],$col['typeValue']).' ';
468             }elseif($col['action'] == 'drop') {
469                 $sql .= 'DROP '.$col['name'].' ';
b5a2f8 470             }
12fcb2 471             if($col['action'] != 'drop') {  
J 472             if($col['defaultValue'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' ";
473             if($col['notNull'] == true) {
474                 $sql .= 'NOT NULL ';
b5a2f8 475             } else {
12fcb2 476                 $sql .= 'NULL ';
b5a2f8 477             }
12fcb2 478             if($col['autoInc'] == true) $sql .= 'auto_increment ';
J 479             $sql.= ',';
e6c1c4 480             //* Index definitions
P 481             if($col['option'] == 'primary') $index .= 'PRIMARY KEY ('.$col['name'].'),';
482             if($col['option'] == 'index') $index .= 'INDEX ('.$col['name'].'),';
483             if($col['option'] == 'unique') $index .= 'UNIQUE ('.$col['name'].'),';
b5a2f8 484             }
12fcb2 485        }
J 486        $sql .= $index;
487        $sql = substr($sql,0,-1);
488        //die($sql);
489        $this->query($sql);
490        return true;
e6c1c4 491     }
b5a2f8 492        
e6c1c4 493     public function dropTable($table_name) 
P 494     {
495         $this->check($table_name);
496         $sql = "DROP TABLE '". $table_name."'";
497         return $this->query($sql);
498     }
b5a2f8 499        
e6c1c4 500     /** Return an array of table names */
P 501     public function getTables($database_name = '')
502     {
503         if($database_name == ''){
504             $database_name = $this->dbName;
505         }
92bc67 506         $result = @mysql_list_tables($database_name);
e6c1c4 507         $tb_names = array();
92bc67 508         for ($i = 0; $i < @mysql_num_rows($result); $i++) {
T 509             $tb_names[$i] = @mysql_tablename($result, $i);
e6c1c4 510         }
P 511         return $tb_names;       
512     }
b5a2f8 513        
T 514        
e6c1c4 515     public function tableInfo($table_name) {
P 516         //* Tabellenfelder einlesen ?
fb3a98 517         if($rows = $this->queryAllRecords('SHOW FIELDS FROM '.$table_name)){
b5a2f8 518         foreach($rows as $row) {
07ba80 519             $name    = $row['Field'];
T 520             $default = $row['Default'];
521             $key     = $row['Key'];
522             $extra   = $row['Extra'];
523             $isnull  = $row['Null'];
524             $type    = $row['Type'];
b5a2f8 525         
e6c1c4 526             $column = array('name' => $name, 'defaultValue' => $default);
b5a2f8 527             //$column["type"] = $type;
e6c1c4 528             if(stristr($key, 'PRI')){ $column['option'] = 'primary'; }
P 529             $column['notNull'] = stristr($isnull,'YES') ? false : true;
530             if($extra == 'auto_increment'){ $column['autoInc'] = true; }         
b5a2f8 531             
e6c1c4 532             //* Get the Data and Metatype
P 533             if( stristr($type, 'int(') ){    $metaType = 'int32'; }
534             if( stristr($type, 'bigint') ){  $metaType = 'int64'; }
535             if( stristr($type, 'char') ) {
b5a2f8 536                 $metaType = 'char';
T 537                 $tmp_typeValue = explode('(',$type);
e6c1c4 538                 $column['typeValue'] = substr($tmp_typeValue[1], 0, -1);  
b5a2f8 539             }
e6c1c4 540             if( stristr($type, 'varchar') ){
b5a2f8 541                 $metaType = 'varchar';
T 542                 $tmp_typeValue = explode('(',$type);
e6c1c4 543                 $column['typeValue'] = substr($tmp_typeValue[1], 0, -1);  
b5a2f8 544             }
12fcb2 545             if(stristr($type,'text'))   $metaType = 'text';
J 546             if(stristr($type,'double')) $metaType = 'double';
547             if(stristr($type,'blob'))   $metaType = 'blob';
b5a2f8 548             
e6c1c4 549             $column['type'] = $metaType;
P 550             $columns[] = $column;
b5a2f8 551         }
T 552             return $columns;
553         } else {
554             return false;
555         }
e6c1c4 556     }
b5a2f8 557        
e6c1c4 558     public function mapType($metaType, $typeValue) {
P 559         //TODO: ? this is not required ?? global $go_api;
560         $metaType = strtolower($metaType);
561         switch ($metaType) {
562         case 'int16':
b5a2f8 563             return 'smallint';
e6c1c4 564         case 'int32':
b5a2f8 565             return 'int';
e6c1c4 566         case 'int64':
b5a2f8 567             return 'bigint';
e6c1c4 568         case 'double':
b5a2f8 569             return 'double';
e6c1c4 570         case 'char':
b5a2f8 571             return 'char';
e6c1c4 572         case 'varchar':
P 573             if($typeValue < 1) die('Datenbank Fehler: F�r diesen Datentyp ist eine L�ngenangabe notwendig.');
b5a2f8 574             return 'varchar('.$typeValue.')';
e6c1c4 575         case 'text':
b5a2f8 576             return 'text';
e6c1c4 577         case 'blob':
b5a2f8 578             return 'blob';
e6c1c4 579         }
P 580     }
12fcb2 581
e6c1c4 582 }
b5a2f8 583
12fcb2 584 ?>