phpMysql.rar

  • q7_382181
    了解作者
  • 1.6KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-01 07:04
    上传日期
源生php连接mysql封装,包含数据查询,删除,修改,增加等。适合刚解除php人员学习参考.
phpMysql.rar
  • 1.php
    614B
  • index.php
    1.4KB
  • test.php
    601B
内容介绍
<?php header("Content-type:text/html;charset=utf-8"); class DBUtils{ private $ychat_host = "localhost"; private $ychat_username = "root"; private $ychat_password = "123456"; private $ychat_database = "m"; private $conn; function __construct(){ $this->connect(); } function dbClose(){ mysql_close($this->conn); } function connect(){ $this->conn = mysql_connect($this->ychat_host,$this->ychat_username,$this->ychat_password) or die ("connection MySQL failed!"); mysql_select_db($this->ychat_database,$this->conn); mysql_query("set names utf8"); } //对mysql_query()、mysql_fetch_array()、mysql_num_rows()函数进行封装 function query($sql){ return mysql_query($sql); } function myArray($result){ return mysql_fetch_array($result); } function rows($result){ return mysql_num_rows($result); } //自定义查询数据方法 function select($table,$tablename,$condition){ return $this->query("SELECT $tablename FROM $table $condition"); } function insert($table,$fields,$value){ $this->query("INSERT INTO $table ($fields) VALUES ($value)"); } function update($table,$change,$condition){ $this->query("UPDATE $table SET $change $condition"); } function delete($table,$condition){ $this->query("DELETE FROM $table $condition"); } } ?>
评论
    相关推荐