X-Git-Url: http://git.dj3c1t.com/?a=blobdiff_plain;f=mw%2Fapp%2Fdata%2Fimpl%2Fmw_pdo_sqlite.php;h=1e4f68eff97cd1776721911a9329fd89f529dcc5;hb=ed558d720ebf6985290c99297f5b1d2c86d1f60a;hp=4ef1696ed51ff755af7b0c6e61fa02c2241feb9e;hpb=0ada6496e6c552c473a5816734b38896ccdd345b;p=mtweb diff --git a/mw/app/data/impl/mw_pdo_sqlite.php b/mw/app/data/impl/mw_pdo_sqlite.php index 4ef1696..1e4f68e 100644 --- a/mw/app/data/impl/mw_pdo_sqlite.php +++ b/mw/app/data/impl/mw_pdo_sqlite.php @@ -49,24 +49,26 @@ } function desc_table($table_name){ - $sql = "SELECT * from information_schema.columns where table_name='".$table_name."'"; - $rst = $this->query($sql); + if(strpos($table_name, "'") !== false){ + throw new Exception($this->exception_out("nom de table avec un simple quote")); + } $desc = array( "name" => $table_name, "attributs" => array() ); + $sql = "PRAGMA table_info(".$table_name.")"; 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 + $rst = $this->query($sql); + while($v_rst = $this->fetch_assoc($rst)){ + $desc["attributs"][$v_rst["name"]] = array( + "name" => $v_rst["name"], + "prymary_key" => isset($v_rst["pk"]) && $v_rst["pk"] ? true : false ); - } + } $this->free_result($rst); } catch(Exception $e){ - throw new Exception($this->exception_out("Impossible de lire la description de la table")); + throw new Exception($this->exception_out("impossible de lire les champs de la table ".$table_name)); } return $desc; }