return $this->query("USE ".$db_name);\r
}
+ 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)){\r
+ $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
+ );
+ }\r
+ $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){\r
if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
$rst = $this->query("SHOW TABLES");\r
return false;\r
}
+ function field_exists($table_name, $field_name){
+ if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);
+ $sql = "SHOW COLUMNS FROM `".$table_name."` LIKE ".$field_name;
+ $rst = $this->query($sql);
+ $exists = false;
+ $v_rst = $this->fetch_assoc($rst);
+ if($v_rst) $exists = true;
+ $this->free_result($rst);
+ return $exists;
+ }
+
function query($query_string){\r
if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password);\r
$result = @mysql_query($query_string, $this->link);\r