Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di thitan
    Registrato dal
    Feb 2001
    Messaggi
    716

    problema con BACKUP database...e campi ENUM

    ciao, qualcuno sà come riconoscere il campo enum in se e i valori assegnati?

    io utilizzo la classe mysql_backup by captain5ive @ yahoo . com, e funziona bene, solo che nei backup, tutte le colonne enum, me le mette vachar(x) dove x è il nuimero massimo di caratteri dell'opzione enum..


    cioè: campo enum('si', 'no', 'tutti') mi diventerà varchar(4).

    ho modificato la calsse in molte sue parti, ma ho provato e era così anche nella versione originale..


    ora, con mysql_field_flags nei campi enum mi erestituisce 'not_null enum', quindi riesco a identificare i campi..ma non riesco a risalire ai valori che possono avere ('si', 'no', 'tutti').

    avete idea?

    posto il pezzo dove identifica il field:
    Codice PHP:
    $fn=mysql_field_name($res2,$b);
                    
    $ft=mysql_field_type($res2,$b);
                    
                    
    $fs=mysql_field_len($res2,$b);
                    
    $ff=mysql_field_flags($res2,$b);
                    
    $sql.="$fn ";
                    
    $is_numeric=false;
                    switch(
    strtolower($ft))
                        {
                        case 
    "int":
                            
    $sql.="int";
                            
    $is_numeric=true;
                            break;
        
                        case 
    "blob":
                            
    $sql.="text";
                            
    $is_numeric=false;
                            break;
        
                        case 
    "real":
                            
    $sql.="real";
                            
    $is_numeric=true;
                            break;
        
                        case 
    "string":
                            
    $sql.="char($fs)";
                            
    $is_numeric=false;
                            break;
        
                        case 
    "unknown":
                            switch(
    intval($fs))
                                {
                                case 
    4://little weakness here...there is no way (thru the PHP/MySQL interface) to tell the difference between a tinyint and a year field type 
                                    
    $sql.="tinyint";
                                    
    $is_numeric=true;
                                    break;
        
                                default:
    //we could get a little more optimzation here! (i.e. check for medium ints, etc.) 
                                    
    $sql.="int";
                                    
    $is_numeric=true;
                                    break; 
                                }
                            break;
        
                        case 
    "timestamp":
                            
    $sql.="timestamp"
                            
    $is_numeric=true;
                            break;
        
                        case 
    "date":
                            
    $sql.="date"
                            
    $is_numeric=false;
                            break;
        
                        case 
    "datetime":
                            
    $sql.="datetime"
                            
    $is_numeric=false;
                            break;
        
                        case 
    "time":
                            
    $sql.="time"
                            
    $is_numeric=false;
                            break;
        
                        default: 
    //future support for field types that are not recognized (hopefully this will work without need for future modification) 
                            
    $sql.=$ft;
                            
    $is_numeric=true//I'm assuming new field types will follow SQL numeric syntax..this is where this support will breakdown 
                            
    break;
                        }
        
                    
    //VERY, VERY IMPORTANT!!! Don't forget to append the flags onto the end of the field creator 

                    
    if (strpos($ff,"unsigned")!=false)
                        {
                        
    //timestamps are a little screwy so we test for them 
                        
    if ($ft!="timestamp"$sql.=" unsigned";
                        }
        
                    if (
    strpos($ff,"zerofill")!=false)
                        {
                        
    //timestamps are a little screwy so we test for them 
                        
    if ($ft!="timestamp"$sql.=" zerofill";
                        }
        
                    if (
    strpos($ff,"auto_increment")!=false$sql.=" auto_increment";
                    
    $sql.=" NOT NULL";
                    if (
    strpos($ff,"primary_key")!=false$sql.=" primary key";
        
                    
    //End of field flags 
        
                    
    if ($b<$nf-1)
                        {
                        
    $sql.=",\n";
                        
    $fl.=$fn.", ";
                        }
                    else
                        {
                        
    $sql.="\n);\n\n";
                        
    $fl.=$fn;
                        }
        
                    
    //we need some of the info generated in this loop later in the algorythm...save what we need to arrays 
                    
    $fna[$b]=$fn;
                    
    $ina[$b]=$is_numeric

    www.inter-rail.it
    travellers, not tourist
    Is cuma cá mhinice a théann tú ar strae; is é is tábhachtaí gurb áil leat do bhealach a aimsiú arís.

  2. #2
    Utente di HTML.it L'avatar di thitan
    Registrato dal
    Feb 2001
    Messaggi
    716
    ps: anche i valori di default, come si pigliano?!

    www.inter-rail.it
    travellers, not tourist
    Is cuma cá mhinice a théann tú ar strae; is é is tábhachtaí gurb áil leat do bhealach a aimsiú arís.

  3. #3
    Utente di HTML.it L'avatar di thitan
    Registrato dal
    Feb 2001
    Messaggi
    716
    ok risolto
    grazie lo stesso

    www.inter-rail.it
    travellers, not tourist
    Is cuma cá mhinice a théann tú ar strae; is é is tábhachtaí gurb áil leat do bhealach a aimsiú arís.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.