<?php

class Mysql{

	//数据库连接句柄
private $link; //返回结果集
private $result; //返回查询数据
private $data; //执行的SQL语句
private $query; public function __construct(){
$this->link = @new mysqli("127.0.0.1","root","chenshuo90909","frame");
if($this->link->connect_errno > 0){
echo "<meta charset='utf-8'>数据库连接失败!"; exit;
}
$this->link->set_charset("utf8");
} //查询
public function select($query){
$this->result = $this->link->query($query);
while($row = $this->result->fetch_assoc()){
$this->data[] = $row;
}
$this->result->free();
return $this->data; } //写入
public function insert($query){
$this->result = $this->link->query($query);
return $this->result;
} //获取最后一次添加记录的主键值
public function insertid(){
return $this->link->insert_id;
} //修改
public function update($query){
$this->result = $this->link->query($query);
return $this->result;
} //删除
public function delete($query){
$this->result = $this->link->query($query);
return $this->result;
} //返回服务器端MySQl版本
public function version(){
return $this->link->server_info;
} //返回数据库所属服务器信息
public function hostinfo(){
return $this->link->host_info;
} //关闭mysql连接
public function __destruct(){
$this->link->close();
} } ?>

  

PHP操作mysql类的更多相关文章

  1. java分享第十七天-03(封装操作mysql类)

     JAVA操作mysql所需jar包:mysql-connector-java.jar代码: import java.sql.*; import java.util.ArrayList; import ...

  2. C#操作Mysql类

    using System;using System.Collections.Generic;using System.Text;using System.Data;using System.Text. ...

  3. LightMysql:为方便操作MySQL而封装的Python类

    原文链接:http://www.danfengcao.info/python/2015/12/26/lightweight-python-mysql-class.html mysqldb是Python ...

  4. .NET 使用 MySql.Data.dll 动态库操作MySql的帮助类--MySqlHelper

    .NET 使用 MySql.Data.dll 动态库操作MySql的帮助类--MySqlHelper 參考演示样例代码,例如以下所看到的: /// <summary> /// MySql ...

  5. C#操作MySQL的类

    C#操作MySQL的类 public class MySqlService { private static log4net.ILog logger = log4net.LogManager.GetL ...

  6. Jave工具——servlet+jsp编程中mysql数据库连接及操作通用工具类

    该工具类是在JavaWeb中连接mysql所用到的通用工具类 该类用于Java+Servlet的编程中,方便数据库的操作,连接,获取其列表值.下面是这个数据库操作类的通用方法,基本上能够用于类里面只含 ...

  7. C#---数据库访问通用类、Access数据库操作类、mysql类 .[转]

    原文链接 //C# 数据库访问通用类 (ADO.NET)using System;using System.Collections.Generic;using System.Text;using Sy ...

  8. C#---数据库访问通用类、Access数据库操作类、mysql类 .

    //C# 数据库访问通用类 (ADO.NET)using System;using System.Collections.Generic;using System.Text;using System. ...

  9. Python3操作MySQL基于PyMySQL封装的类

    Python3操作MySQL基于PyMySQL封装的类   在未使用操作数据库的框架开发项目的时候,我们需要自己处理数据库连接问题,今天在做一个Python的演示项目,写一个操作MySQL数据库的类, ...

随机推荐

  1. Spring中实现监听的方法

    在未使用框架进行编程的时候,我们常常在web.xml中加上这样一段话 <listener> <listener-class>XXX</listener-class> ...

  2. 一款值得推荐的shell工具

    1. 一款比较出色的shell工具 熟练的运用shell语言可以提高我们的工作效率,而一款好的shell工具能提高学习的效率,fish shell就是这样一款工具.并且是一款跨平台的工具, 同时可以在 ...

  3. HTML day03表格与表单

    1.表格 一般格式: <table> <thead><!--表格头--> <tr> <th></th> </tr>& ...

  4. IOS 使用动态库(dylib)和动态加载framework

    在iphone上使用动态库的多为dylib文件,这些文件使用标准的dlopen方式来使用是可以的.那相同的在使用framework文件也可以当做动态库的方式来动态加载,这样就可以比较自由的使用appl ...

  5. HttpURLConnection请求网络数据的GET请求

    //清单文件中添加权限 <uses-permission android:name="android.permission.INTERNET"/> new Thread ...

  6. GameUnity 2.0 文档(五) 人工智能之---------------Flocking算法 (聚集,分散,列队 )

    AI是游戏的灵魂,是人物的智商,是让玩家觉得游戏是否幼稚的重要判断功能,下面我将介绍国外流行,国内不行的,ai算法. 主要介绍  Flocking  和 Reciprocal Velocity Obs ...

  7. GenericApp SampleApp SimpleAp的区别

    SampleApp3.2 Zigbee2007 协议栈实验例程表演说明C:\Texas Instruments\ZStack-2.0.0-1.2.0\Projects\zstack\Samples\S ...

  8. java 类与对象

    class XiyoujiRenwu { float height,weight; String head, ear; void speak(String s) { System.out.printl ...

  9. 让横向ul在页面中水平居中的方法

    在导航的布局中,导航条会用横向布局的ul li.如果要让其居中,怎么办呢? 第一种方法: ul{text-align:center;} li{display:inline} 这种方法不适合ie低版本. ...

  10. CentOS下编译安装Apache(httpd)

    官网下载最新版本的apache, apr, apr-util http://httpd.apache.org/download.cgi#apache24 http://apr.apache.org/d ...