2929
3030 class db
3131 {
32- var $ dbHost = "" ; // hostname of the MySQL server
33- var $ dbName = "" ; // logical database name on that server
34- var $ dbUser = "" ; // database authorized user
35- var $ dbPass = "" ; // user's password
32+ var $ dbHost = '' ; // hostname of the MySQL server
33+ var $ dbName = '' ; // logical database name on that server
34+ var $ dbUser = '' ; // database authorized user
35+ var $ dbPass = '' ; // user's password
3636 var $ linkId = 0 ; // last result of mysql_connect()
3737 var $ queryId = 0 ; // last result of mysql_query()
3838 var $ record = array (); // last record fetched
3939 var $ autoCommit = 1 ; // Autocommit Transactions
4040 var $ currentRow ; // current row number
4141 var $ errorNumber = 0 ; // last error number
42- var $ errorMessage = "" ; // last error message
43- var $ errorLocation = "" ;// last error location
42+ var $ errorMessage = '' ; // last error message
43+ var $ errorLocation = '' ;// last error location
4444 var $ show_error_messages = true ;
4545
4646 // constructor
4747 function db ()
4848 {
4949
5050 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 " ];
51+ $ this ->dbHost = $ conf [' db_host ' ];
52+ $ this ->dbName = $ conf [' db_database ' ];
53+ $ this ->dbUser = $ conf [' db_user ' ];
54+ $ this ->dbPass = $ conf [' db_password ' ];
5555 $ this ->dbCharset = $ conf ['db_charset ' ];
5656 //$this->connect();
5757 }
@@ -66,7 +66,7 @@ function updateError($location)
6666 if ($ this ->errorNumber && $ this ->show_error_messages && method_exists ($ app ,'log ' ))
6767 {
6868 // echo('<br /><b>'.$this->errorLocation.'</b><br />'.$this->errorMessage);
69- $ app ->log ($ this ->errorLocation ." " .$ this ->errorMessage ,LOGLEVEL_WARN );
69+ $ app ->log ($ this ->errorLocation .' ' .$ this ->errorMessage ,LOGLEVEL_WARN );
7070 //flush();
7171 }
7272 }
@@ -282,16 +282,16 @@ public function datalogSave($db_table, $action, $primary_field, $primary_id, $re
282282 unset($ tmp );
283283
284284 // Insert the server_id, if the record has a server_id
285- $ server_id = (isset ($ record_old [" server_id " ]) && $ record_old [" server_id " ] > 0 )?$ record_old [" server_id " ]:0 ;
286- if (isset ($ record_new [" server_id " ])) $ server_id = $ record_new [" server_id " ];
285+ $ server_id = (isset ($ record_old [' server_id ' ]) && $ record_old [' server_id ' ] > 0 )?$ record_old [' server_id ' ]:0 ;
286+ if (isset ($ record_new [' server_id ' ])) $ server_id = $ record_new [' server_id ' ];
287287
288288
289289 if ($ diff_num > 0 ) {
290290 //print_r($diff_num);
291291 //print_r($diffrec_full);
292292 $ diffstr = $ app ->db ->quote (serialize ($ diffrec_full ));
293- $ username = $ app ->db ->quote ($ _SESSION [" s " ][ " user " ][ " username " ]);
294- $ dbidx = $ primary_field ." : " .$ primary_id ;
293+ $ username = $ app ->db ->quote ($ _SESSION [' s ' ][ ' user ' ][ ' username ' ]);
294+ $ dbidx = $ primary_field .' : ' .$ primary_id ;
295295
296296 if ($ action == 'INSERT ' ) $ action = 'i ' ;
297297 if ($ action == 'UPDATE ' ) $ action = 'u ' ;
@@ -383,27 +383,27 @@ function Transaction($action) {
383383 */
384384
385385 function createTable ($ table_name ,$ columns ) {
386- $ index = "" ;
386+ $ index = '' ;
387387 $ sql = "CREATE TABLE $ table_name ( " ;
388388 foreach ($ columns as $ col ){
389- $ sql .= $ col [" name " ]. " " .$ this ->mapType ($ col [" type " ],$ col [" typeValue " ])." " ;
389+ $ sql .= $ col [' name ' ]. ' ' .$ this ->mapType ($ col [' type ' ],$ col [' typeValue ' ]).' ' ;
390390
391- if ($ col [" defaultValue " ] != "" ) $ sql .= "DEFAULT ' " .$ col [" defaultValue " ]."' " ;
392- if ($ col [" notNull " ] == true ) {
393- $ sql .= " NOT NULL " ;
391+ if ($ col [' defaultValue ' ] != '' ) $ sql .= "DEFAULT ' " .$ col [' defaultValue ' ]."' " ;
392+ if ($ col [' notNull ' ] == true ) {
393+ $ sql .= ' NOT NULL ' ;
394394 } else {
395- $ sql .= " NULL " ;
395+ $ sql .= ' NULL ' ;
396396 }
397- if ($ col [" autoInc " ] == true ) $ sql .= " auto_increment " ;
398- $ sql .= " , " ;
397+ if ($ col [' autoInc ' ] == true ) $ sql .= ' auto_increment ' ;
398+ $ sql .= ' , ' ;
399399 // key Definitionen
400- if ($ col [" option " ] == " primary " ) $ index .= "PRIMARY KEY ( " .$ col [" name " ]."), " ;
401- if ($ col [" option " ] == " index " ) $ index .= "INDEX ( " .$ col [" name " ]."), " ;
402- if ($ col [" option " ] == " unique " ) $ index .= "UNIQUE ( " .$ col [" name " ]."), " ;
400+ if ($ col [' option ' ] == ' primary ' ) $ index .= "PRIMARY KEY ( " .$ col [' name ' ]."), " ;
401+ if ($ col [' option ' ] == ' index ' ) $ index .= "INDEX ( " .$ col [' name ' ]."), " ;
402+ if ($ col [' option ' ] == ' unique ' ) $ index .= "UNIQUE ( " .$ col [' name ' ]."), " ;
403403 }
404404 $ sql .= $ index ;
405405 $ sql = substr ($ sql ,0 ,-1 );
406- $ sql .= " ) " ;
406+ $ sql .= ' ) ' ;
407407
408408 $ this ->query ($ sql );
409409 return true ;
@@ -423,29 +423,29 @@ function createTable($table_name,$columns) {
423423
424424 */
425425 function alterTable ($ table_name ,$ columns ) {
426- $ index = "" ;
426+ $ index = '' ;
427427 $ sql = "ALTER TABLE $ table_name " ;
428428 foreach ($ columns as $ col ){
429- if ($ col [" action " ] == 'add ' ) {
430- $ sql .= "ADD " .$ col [" name " ]. " " .$ this ->mapType ($ col [" type " ],$ col [" typeValue " ])." " ;
431- } elseif ($ col [" action " ] == 'alter ' ) {
432- $ sql .= "CHANGE " .$ col [" name " ]." " .$ col [" name_new " ]. " " .$ this ->mapType ($ col [" type " ],$ col [" typeValue " ])." " ;
433- } elseif ($ col [" action " ] == 'drop ' ) {
434- $ sql .= "DROP " .$ col [" name " ]. " " ;
429+ if ($ col [' action ' ] == 'add ' ) {
430+ $ sql .= "ADD " .$ col [' name ' ]. ' ' .$ this ->mapType ($ col [' type ' ],$ col [' typeValue ' ]).' ' ;
431+ } elseif ($ col [' action ' ] == 'alter ' ) {
432+ $ sql .= "CHANGE " .$ col [' name ' ]." " .$ col [' name_new ' ]. ' ' .$ this ->mapType ($ col [' type ' ],$ col [' typeValue ' ]).' ' ;
433+ } elseif ($ col [' action ' ] == 'drop ' ) {
434+ $ sql .= "DROP " .$ col [' name ' ]. ' ' ;
435435 }
436- if ($ col [" action " ] != 'drop ' ) {
437- if ($ col [" defaultValue " ] != "" ) $ sql .= "DEFAULT ' " .$ col [" defaultValue " ]."' " ;
438- if ($ col [" notNull " ] == true ) {
439- $ sql .= " NOT NULL " ;
436+ if ($ col [' action ' ] != 'drop ' ) {
437+ if ($ col [' defaultValue ' ] != '' ) $ sql .= "DEFAULT ' " .$ col [' defaultValue ' ]."' " ;
438+ if ($ col [' notNull ' ] == true ) {
439+ $ sql .= ' NOT NULL ' ;
440440 } else {
441- $ sql .= " NULL " ;
441+ $ sql .= ' NULL ' ;
442442 }
443- if ($ col [" autoInc " ] == true ) $ sql .= " auto_increment " ;
444- $ sql .= " , " ;
443+ if ($ col [' autoInc ' ] == true ) $ sql .= ' auto_increment ' ;
444+ $ sql .= ' , ' ;
445445 // key Definitionen
446- if ($ col [" option " ] == " primary " ) $ index .= "PRIMARY KEY ( " .$ col [" name " ]."), " ;
447- if ($ col [" option " ] == " index " ) $ index .= "INDEX ( " .$ col [" name " ]."), " ;
448- if ($ col [" option " ] == " unique " ) $ index .= "UNIQUE ( " .$ col [" name " ]."), " ;
446+ if ($ col [' option ' ] == ' primary ' ) $ index .= "PRIMARY KEY ( " .$ col [' name ' ]."), " ;
447+ if ($ col [' option ' ] == ' index ' ) $ index .= "INDEX ( " .$ col [' name ' ]."), " ;
448+ if ($ col [' option ' ] == ' unique ' ) $ index .= "UNIQUE ( " .$ col [' name ' ]."), " ;
449449 }
450450 }
451451 $ sql .= $ index ;
@@ -505,38 +505,38 @@ function tableInfo($table_name) {
505505
506506 $ column = array ();
507507
508- $ column [" name " ] = $ name ;
509- //$column[" type" ] = $type;
510- $ column [" defaultValue " ] = $ default ;
511- if (stristr ($ key ," PRI " )) $ column [" option " ] = " primary " ;
512- if (stristr ($ isnull ," YES " )) {
513- $ column [" notNull " ] = false ;
508+ $ column [' name ' ] = $ name ;
509+ //$column[' type' ] = $type;
510+ $ column [' defaultValue ' ] = $ default ;
511+ if (stristr ($ key ,' PRI ' )) $ column [' option ' ] = ' primary ' ;
512+ if (stristr ($ isnull ,' YES ' )) {
513+ $ column [' notNull ' ] = false ;
514514 } else {
515- $ column [" notNull " ] = true ;
515+ $ column [' notNull ' ] = true ;
516516 }
517- if ($ extra == 'auto_increment ' ) $ column [" autoInc " ] = true ;
517+ if ($ extra == 'auto_increment ' ) $ column [' autoInc ' ] = true ;
518518
519519
520520 // Type in Metatype umsetzen
521521
522- if (stristr ($ type ," int( " )) $ metaType = 'int32 ' ;
523- if (stristr ($ type ," bigint " )) $ metaType = 'int64 ' ;
524- if (stristr ($ type ," char " )) {
522+ if (stristr ($ type ,' int( ' )) $ metaType = 'int32 ' ;
523+ if (stristr ($ type ,' bigint ' )) $ metaType = 'int64 ' ;
524+ if (stristr ($ type ,' char ' )) {
525525 $ metaType = 'char ' ;
526526 $ tmp_typeValue = explode ('( ' ,$ type );
527- $ column [" typeValue " ] = substr ($ tmp_typeValue [1 ],0 ,-1 );
527+ $ column [' typeValue ' ] = substr ($ tmp_typeValue [1 ],0 ,-1 );
528528 }
529- if (stristr ($ type ," varchar " )) {
529+ if (stristr ($ type ,' varchar ' )) {
530530 $ metaType = 'varchar ' ;
531531 $ tmp_typeValue = explode ('( ' ,$ type );
532- $ column [" typeValue " ] = substr ($ tmp_typeValue [1 ],0 ,-1 );
532+ $ column [' typeValue ' ] = substr ($ tmp_typeValue [1 ],0 ,-1 );
533533 }
534- if (stristr ($ type ," text " )) $ metaType = 'text ' ;
535- if (stristr ($ type ," double " )) $ metaType = 'double ' ;
536- if (stristr ($ type ," blob " )) $ metaType = 'blob ' ;
534+ if (stristr ($ type ,' text ' )) $ metaType = 'text ' ;
535+ if (stristr ($ type ,' double ' )) $ metaType = 'double ' ;
536+ if (stristr ($ type ,' blob ' )) $ metaType = 'blob ' ;
537537
538538
539- $ column [" type " ] = $ metaType ;
539+ $ column [' type ' ] = $ metaType ;
540540
541541 $ columns [] = $ column ;
542542 }
@@ -595,7 +595,7 @@ function mapType($metaType,$typeValue) {
595595 return 'char ' ;
596596 break ;
597597 case 'varchar ' :
598- if ($ typeValue < 1 ) die (" Datenbank Fehler: Für diesen Datentyp ist eine Längenangabe notwendig. " );
598+ if ($ typeValue < 1 ) die (' Database failure: Lenght required for these data types. ' );
599599 return 'varchar( ' .$ typeValue .') ' ;
600600 break ;
601601 case 'text ' :
@@ -609,4 +609,4 @@ function mapType($metaType,$typeValue) {
609609
610610 }
611611
612- ?>
612+ ?>
0 commit comments