1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| public function schemaTable($nom_table)
{
// recherche de la liste des attributs de la table
$liste_attr = mysql_list_fields($this->nom_base, $nom_table, $this->connexion);
if(!$liste_attr) throw new Exception("Probleme d'analyse de $nom_table");
// recherche des attributs et stockage dans le tableau suivant
for($i = 0; $i < mysql_num_fields($liste_attr); $i++)
{
$nom = mysql_field_name($liste_attr, $i);
$schema[$nom]['longueur'] = mysql_field_len($liste_attr, $i);
$schema[$nom]['type'] = mysql_field_type($liste_attr, $i);
$schema[$nom]['cle_primaire'] = substr_count(mysql_field_flags($liste_attr, $i), "primary_key");
$schema[$nom]['not_null'] = substr_count(mysql_field_flags($liste_attr, $i), "not_null");
$schema[$nom]['defaut'] = substr_count(mysql_field_flags($liste_attr, $i), "default");
$schema[$nom]['unique'] = substr_count(mysql_field_flags($liste_attr, $i), "unique");
$schema[$nom]['auto_increment'] = substr_count(mysql_field_flags($liste_attr, $i), "AUTO_INCREMENT");
}
return $schema;
} |
Partager