tbrehm
2012-04-12 471560c60fb17b1abe7561fda41f01e129fc7ff1
commit | author | age
b5a2f8 1 <?php
T 2 /*
436ed8 3 Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
260     public function datalogSave($db_table, $action, $primary_field, $primary_id, $record_old, $record_new) {
261         global $app,$conf;
262
263         // Insert backticks only for incomplete table names.
264         if(stristr($db_table,'.')) {
265             $escape = '';
266         } else {
267             $escape = '`';
268         }
269
270         $tmp = $this->diffrec($record_old, $record_new);
271         $diffrec_full = $tmp['diff_rec'];
272         $diff_num = $tmp['diff_num'];
273         unset($tmp);
274         
958705 275         // Insert the server_id, if the record has a server_id
12fcb2 276         $server_id = (isset($record_old['server_id']) && $record_old['server_id'] > 0)?$record_old['server_id']:0;
J 277         if(isset($record_new['server_id'])) $server_id = $record_new['server_id'];
430a0f 278         
958705 279
T 280         if($diff_num > 0) {
74829e 281             //print_r($diff_num);
T 282             //print_r($diffrec_full);
958705 283             $diffstr = $app->db->quote(serialize($diffrec_full));
12fcb2 284             $username = $app->db->quote($_SESSION['s']['user']['username']);
J 285             $dbidx = $primary_field.':'.$primary_id;
958705 286                         
T 287             if($action == 'INSERT') $action = 'i';
288             if($action == 'UPDATE') $action = 'u';
289             if($action == 'DELETE') $action = 'd';
290             $sql = "INSERT INTO sys_datalog (dbtable,dbidx,server_id,action,tstamp,user,data) VALUES ('".$db_table."','$dbidx','$server_id','$action','".time()."','$username','$diffstr')";
291             $app->db->query($sql);
292         }
293
294         return true;
295     }
296     
eea5cf 297     //** Inserts a record and saves the changes into the datalog
430a0f 298     public function datalogInsert($tablename, $insert_data, $index_field) {
T 299         global $app;
300         
471560 301         if(is_array($insert_data)) {
T 302             $key_str = '';
303             $val_str = '';
304             foreach($insert_data as $key => $val) {
305                 $key_str .= "`".$key ."`,";
306                 $val_str .= "'".$this->quote($val)."',";
307             }
308             $insert_data_str = '('.$key_str.') VALUES ('.$val_str.')';
309         } else {
310             $insert_data_str = $insert_data;
311         }
312         
430a0f 313         $old_rec = array();
471560 314         $this->query("INSERT INTO $tablename $insert_data_str");
430a0f 315         $index_value = $this->insertID();
T 316         $new_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'");
317         $this->datalogSave($tablename, 'INSERT', $index_field, $index_value, $old_rec, $new_rec);
318         
13d323 319         return $index_value;
430a0f 320     }
T 321     
322     //** Updates a record and saves the changes into the datalog
fddedd 323     public function datalogUpdate($tablename, $update_data, $index_field, $index_value, $force_update = false) {
958705 324         global $app;
T 325         
fddedd 326         if($force_update == true) {
T 327             $old_rec = array();
328         } else {
329             $old_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'");
330         }
471560 331         
T 332         if(is_array($update_data)) {
333             $update_data_str = '';
334             foreach($update_data as $key => $val) {
335                 $update_data_str .= "`".$key ."` = '".$this->quote($val)."',";
336             }
337         } else {
338             $update_data_str = $update_data;
339         }
340         
341         $this->query("UPDATE $tablename SET $update_data_str WHERE $index_field = '$index_value'");
958705 342         $new_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'");
T 343         $this->datalogSave($tablename, 'UPDATE', $index_field, $index_value, $old_rec, $new_rec);
344         
345         return true;
346     }
430a0f 347     
T 348     //** Deletes a record and saves the changes into the datalog
349     public function datalogDelete($tablename, $index_field, $index_value) {
350         global $app;
351         
352         $old_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'");
353         $this->query("DELETE FROM $tablename WHERE $index_field = '$index_value'");
354         $new_rec = array();
355         $this->datalogSave($tablename, 'DELETE', $index_field, $index_value, $old_rec, $new_rec);
356         
357         return true;
358     }
12fcb2 359
J 360
b5a2f8 361        
e6c1c4 362     public function closeConn()
P 363     {
55da90 364         if($this->linkId)
B 365         {
366             mysql_close($this->linkId);
367             return true;
368         } else { return false; }
e6c1c4 369     }
12fcb2 370     
55da90 371     public function freeResult($query) 
e6c1c4 372     {
55da90 373         if(mysql_free_result($query))
B 374         {
375             return true;
376         } else {
377             return false;
378         }
e6c1c4 379     }
430a0f 380     
T 381     /*
e6c1c4 382     public function delete()
P 383     {
384     }
430a0f 385     */
T 386     
387     /*
e6c1c4 388     public function Transaction($action)
P 389     {
390         //action = begin, commit oder rollback
391     }
430a0f 392     */
e6c1c4 393     
P 394     /** Creates a database table with the following format for the $columns array   
395     * <code>
396     * $columns = array(action =>   add | alter | drop
397     *                  name =>     Spaltenname
398     *                  name_new => neuer Spaltenname, nur bei 'alter' belegt
399     *                  type =>     42go-Meta-Type: int16, int32, int64, double, char, varchar, text, blob
400     *                  typeValue => Wert z.B. bei Varchar
401     *                  defaultValue =>  Default Wert
402     *                  notNull =>   true | false
403     *                  autoInc =>   true | false
404     *                  option =>   unique | primary | index)
405     * </code>   
406     */
430a0f 407     
T 408     
e6c1c4 409     public function createTable($table_name, $columns)
P 410     {
411         $index = '';
412         $sql = "CREATE TABLE $table_name (";
413         foreach($columns as $col){
414             $sql .= $col['name'].' '.$this->mapType($col['type'], $col['typeValue']).' ';
415             //* Set default value
010876 416             if(isset($col['defaultValue']) && $col['defaultValue'] != '') {
e6c1c4 417                 if($col['defaultValue'] == 'NULL' or $col['defaultValue'] == 'NOT NULL') {
P 418                     $sql .= 'DEFAULT '.$col['defaultValue'].' ';
419                 } else {
420                     $sql .= "DEFAULT '".$col['defaultValue']."' ";
421                 }
422             } elseif($col['defaultValue'] != false) {
423                 $sql .= "DEFAULT '' ";
424             }
010876 425             if(isset($col['defaultValue']) && $col['defaultValue'] != 'NULL' && $col['defaultValue'] != 'NOT NULL') {
e6c1c4 426                 if($col['notNull'] == true) {
P 427                     $sql .= 'NOT NULL ';
428                 } else {
429                     $sql .= 'NULL ';
430                 }
431             }
010876 432             if(isset($col['autoInc']) && $col['autoInc'] == true){ $sql .= 'auto_increment '; }
e6c1c4 433             $sql.= ',';
P 434             //* Index Definitions
010876 435             if(isset($col['option']) && $col['option'] == 'primary'){ $index .= 'PRIMARY KEY ('.$col['name'].'),'; }
T 436             if(isset($col['option']) && $col['option'] == 'index'){   $index .= 'INDEX ('.$col['name'].'),'; }
437             if(isset($col['option']) && $col['option'] == 'unique'){  $index .= 'UNIQUE ('.$col['name'].'),'; }
12fcb2 438        }
b5a2f8 439        $sql .= $index;
T 440        $sql = substr($sql,0,-1);
12fcb2 441        $sql .= ')';
b5a2f8 442        $this->query($sql);
T 443        return true;
e6c1c4 444     }
b5a2f8 445        
e6c1c4 446     /** Changes a table definition. The format for the $columns array is 
P 447     * <code>
448     * $columns = array(action =>   add | alter | drop
449     *                  name =>     Spaltenname
450     *                 name_new => neuer Spaltenname, nur bei 'alter' belegt
451     *                 type =>     42go-Meta-Type: int16, int32, int64, double, char, varchar, text, blob
452     *                 typeValue => Wert z.B. bei Varchar
453     *                 defaultValue =>  Default Wert
454     *                 notNull =>   true | false
455     *                 autoInc =>   true | false
456     *                 option =>   unique | primary | index)
457     */
458     public function alterTable($table_name,$columns)
459     {
12fcb2 460        $index = '';
J 461        $sql = "ALTER TABLE $table_name ";
462        foreach($columns as $col){
e6c1c4 463             if($col['action'] == 'add'){
12fcb2 464                 $sql .= 'ADD '.$col['name'].' '.$this->mapType($col['type'],$col['typeValue']).' ';
e6c1c4 465             }elseif($col['action'] == 'alter') {
P 466                 $sql .= 'CHANGE '.$col['name'].' '.$col['name_new'].' '.$this->mapType($col['type'],$col['typeValue']).' ';
467             }elseif($col['action'] == 'drop') {
468                 $sql .= 'DROP '.$col['name'].' ';
b5a2f8 469             }
12fcb2 470             if($col['action'] != 'drop') {  
J 471             if($col['defaultValue'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' ";
472             if($col['notNull'] == true) {
473                 $sql .= 'NOT NULL ';
b5a2f8 474             } else {
12fcb2 475                 $sql .= 'NULL ';
b5a2f8 476             }
12fcb2 477             if($col['autoInc'] == true) $sql .= 'auto_increment ';
J 478             $sql.= ',';
e6c1c4 479             //* Index definitions
P 480             if($col['option'] == 'primary') $index .= 'PRIMARY KEY ('.$col['name'].'),';
481             if($col['option'] == 'index') $index .= 'INDEX ('.$col['name'].'),';
482             if($col['option'] == 'unique') $index .= 'UNIQUE ('.$col['name'].'),';
b5a2f8 483             }
12fcb2 484        }
J 485        $sql .= $index;
486        $sql = substr($sql,0,-1);
487        //die($sql);
488        $this->query($sql);
489        return true;
e6c1c4 490     }
b5a2f8 491        
e6c1c4 492     public function dropTable($table_name) 
P 493     {
494         $this->check($table_name);
495         $sql = "DROP TABLE '". $table_name."'";
496         return $this->query($sql);
497     }
b5a2f8 498        
e6c1c4 499     /** Return an array of table names */
P 500     public function getTables($database_name = '')
501     {
502         if($database_name == ''){
503             $database_name = $this->dbName;
504         }
92bc67 505         $result = @mysql_list_tables($database_name);
e6c1c4 506         $tb_names = array();
92bc67 507         for ($i = 0; $i < @mysql_num_rows($result); $i++) {
T 508             $tb_names[$i] = @mysql_tablename($result, $i);
e6c1c4 509         }
P 510         return $tb_names;       
511     }
b5a2f8 512        
T 513        
e6c1c4 514     public function tableInfo($table_name) {
P 515         //* Tabellenfelder einlesen ?
fb3a98 516         if($rows = $this->queryAllRecords('SHOW FIELDS FROM '.$table_name)){
b5a2f8 517         foreach($rows as $row) {
07ba80 518             $name    = $row['Field'];
T 519             $default = $row['Default'];
520             $key     = $row['Key'];
521             $extra   = $row['Extra'];
522             $isnull  = $row['Null'];
523             $type    = $row['Type'];
b5a2f8 524         
e6c1c4 525             $column = array('name' => $name, 'defaultValue' => $default);
b5a2f8 526             //$column["type"] = $type;
e6c1c4 527             if(stristr($key, 'PRI')){ $column['option'] = 'primary'; }
P 528             $column['notNull'] = stristr($isnull,'YES') ? false : true;
529             if($extra == 'auto_increment'){ $column['autoInc'] = true; }         
b5a2f8 530             
e6c1c4 531             //* Get the Data and Metatype
P 532             if( stristr($type, 'int(') ){    $metaType = 'int32'; }
533             if( stristr($type, 'bigint') ){  $metaType = 'int64'; }
534             if( stristr($type, 'char') ) {
b5a2f8 535                 $metaType = 'char';
T 536                 $tmp_typeValue = explode('(',$type);
e6c1c4 537                 $column['typeValue'] = substr($tmp_typeValue[1], 0, -1);  
b5a2f8 538             }
e6c1c4 539             if( stristr($type, 'varchar') ){
b5a2f8 540                 $metaType = 'varchar';
T 541                 $tmp_typeValue = explode('(',$type);
e6c1c4 542                 $column['typeValue'] = substr($tmp_typeValue[1], 0, -1);  
b5a2f8 543             }
12fcb2 544             if(stristr($type,'text'))   $metaType = 'text';
J 545             if(stristr($type,'double')) $metaType = 'double';
546             if(stristr($type,'blob'))   $metaType = 'blob';
b5a2f8 547             
e6c1c4 548             $column['type'] = $metaType;
P 549             $columns[] = $column;
b5a2f8 550         }
T 551             return $columns;
552         } else {
553             return false;
554         }
e6c1c4 555     }
b5a2f8 556        
e6c1c4 557     public function mapType($metaType, $typeValue) {
P 558         //TODO: ? this is not required ?? global $go_api;
559         $metaType = strtolower($metaType);
560         switch ($metaType) {
561         case 'int16':
b5a2f8 562             return 'smallint';
e6c1c4 563         case 'int32':
b5a2f8 564             return 'int';
e6c1c4 565         case 'int64':
b5a2f8 566             return 'bigint';
e6c1c4 567         case 'double':
b5a2f8 568             return 'double';
e6c1c4 569         case 'char':
b5a2f8 570             return 'char';
e6c1c4 571         case 'varchar':
P 572             if($typeValue < 1) die('Datenbank Fehler: F�r diesen Datentyp ist eine L�ngenangabe notwendig.');
b5a2f8 573             return 'varchar('.$typeValue.')';
e6c1c4 574         case 'text':
b5a2f8 575             return 'text';
e6c1c4 576         case 'blob':
b5a2f8 577             return 'blob';
e6c1c4 578         }
P 579     }
12fcb2 580
e6c1c4 581 }
b5a2f8 582
12fcb2 583 ?>