X-Git-Url: http://git.dj3c1t.com/?a=blobdiff_plain;f=mw%2Fapp%2Fdata%2Fimpl%2Fmw_mysql.php;h=ba8f56a13a1a4c4e17f7c2c3c6b09f105f833e59;hb=a38a9452cebc53e5d865f6b5c31c006180de88f9;hp=991ac4d6164bd045f6d592ee4c25011c652f3df0;hpb=4bc0f6efc262d712b5c6f09375548bf17cd1576d;p=mtweb diff --git a/mw/app/data/impl/mw_mysql.php b/mw/app/data/impl/mw_mysql.php index 991ac4d..ba8f56a 100644 --- a/mw/app/data/impl/mw_mysql.php +++ b/mw/app/data/impl/mw_mysql.php @@ -38,6 +38,29 @@ return $this->query("USE ".$db_name); } + function desc_table($table_name){ + $sql = "SELECT * from information_schema.columns where table_name='".$table_name."'"; + $rst = $this->query($sql); + $desc = array( + "name" => $table_name, + "attributs" => array() + ); + try{ + while($v_rst = $this->fetch_assoc($rst)){ + $desc["attributs"][$v_rst["COLUMN_NAME"]] = array( + "name" => $v_rst["COLUMN_NAME"], + "prymary_key" => $v_rst["COLUMN_KEY"] == "PRI" ? true : false, + "auto_increment" => $v_rst["EXTRA"] == "auto_increment" ? true : false + ); + } + $this->free_result($rst); + } + catch(Exception $e){ + throw new Exception($this->exception_out("Impossible de lire la description de la table")); + } + return $desc; + } + function table_exists($table){ if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password); $rst = $this->query("SHOW TABLES");