mysql操作类(12)
来源:未知 责任编辑:责任编辑 发表时间:2015-10-08 14:15 点击:次
}
}
//以数组的形式返回主机中所有的数据库名
public function databases(){
$rsPtr=mysql_list_dbs($this->conn);
$i=0;
$cnt=mysql_num_rows($rsPtr);
while ($i<$cnt){
$rs[]=mysql_db_name($rsPtr,$i);
$i++;
}
return $rs;
}
//查询数据库下所有的表
public function show_tables($database_name){
$this->query("show tables");
echo "现有数据库:".$amount=$this->db_num_rows($rs);
echo "<br>";
$i=1;
while ($row=$this->fetch_array($rs)){
$columnName="Tables_in_".$database_name;
echo "$i $row[$columnName]";
echo "<br>";
$i++;
}
}
// 取得结果集
public function fetch_array($resultt=""){
if($resultt!=""){
return mysql_fetch_array($resultt);
}else {
return mysql_fetch_array($this->result);
}
}
//取得结果数 $row['content']
public function mysql_result_li(){
return mysql_result($str);
}
//获取关联数组 $row['字段名']
public function fetch_assoc(){
return mysql_fetch_assoc($this->result);
}
//获取数字索引数组 $row[0] $row[1] $row[2]
public function fetch_row(){
return mysql_fetch_row($this->result);
}
//获取对象数组,使用$row->content
public function fetch_Object(){
return mysql_fetch_object($this->result);
}
//简化查询select
public function findall($table){
$this->query("select* from $table");
}
//简化查询select
public function select($table,$columnName="*",$condition='',$debug=''){
$condition=$condition?'where'.$condition:null;
if($debug){
echo "select $columnName from $table $condition";
}else{
$this->query("select $columnName from $table $condition");
}
}
//简化删除del
public function delete($table,$condition,$url=''){
if($this->query("delete from $table where $condition")){
if(!empty($url)){
$this->Get_admin_msg($url,'删除成功');
相关新闻>>
- 发表评论
-
- 最新评论 更多>>