phpBMS

Ticket #152: db.php.patch

File db.php.patch, 1.1 KB (added by anonymous, 3 years ago)
  • include/db.php

     
    321321                        return $thereturn; 
    322322                } 
    323323                 
     324                 
     325                /* 
     326                 * getFieldsFromTableAsCSV get Fields from table with or without auto_increment Fields  
     327                 * @param       $table  Tablename 
     328                 * @param       $with_auto_increment if true include auto_increment Fields, if false no auto_increment 
     329                 * @return      string comma separiert Fieldlist for SQL-Syntax 
     330                 * @author      m.waldeck@ibased.de 
     331                 * @todo        Errorhandling 
     332                 */ 
     333                function getFieldsFromTableAsCSV ($table, $with_auto_increment = false) 
     334                { 
     335 
     336                        $querystatement = "desc " . $table; 
     337                        $queryresult = $this->query($querystatement); 
     338                         
     339                        if ( !$queryresult ) return FALSE; 
     340                         
     341                        $fields =''; 
     342                        while ($cols = $this->fetchArray ($queryresult)) 
     343                        { 
     344                                if ( !$with_auto_increment && $cols['Extra'] == 'auto_increment' ) continue; 
     345                                $fields .= "`" . $cols['Field'] . "`,";                          
     346                        } 
     347                        $fields = substr ($fields,0,-1);                         
     348                        if ( $fields == '' ) return FALSE;                       
     349                         
     350                        return $fields; 
     351                }                
     352                 
    324353}//end db class 
    325354?> 
     355 No newline at end of file 
Scanned by Orvant Copyright © 2010 Kreotek, LLC. All Rights reserved.