<?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. WNDCLASS 窗口类结构

    Windows 的窗口总是基于窗口类来创建的,窗口类同时确定了处理窗口消息的窗口过程(回调函数). 在创建应用程序窗口之前,必须调用 RegisterClass 函数来注册窗口类.该函数只需要一个参数 ...

  2. python3 与 python2的 区别比较

    http://sebug.net/paper/books/dive-into-python3/porting-code-to-python-3-with-2to3.html

  3. 4D(DRG、DLG、DOM、DEM)数据 概念

    抱歉原文链接未知 Technorati 标签: DRG,DLG,DOM,DEM 以下有不同的说法,但是意思都很相近. 一. DOM (数字正射影像图):利用数字高程模型对扫描处理的数字化的航空相片.遥 ...

  4. ubuntu上的mysql数据库双机备份设置

    配置环境: myslq 5.5.3 + ubuntu server 12.04 一.配置MySQL主服务器(192.168.0.1) 1.增加一个账号专门用于同步 1 mysql>grant r ...

  5. WordPress安装到zen-cart产品页中

    把WordPress安装到zen-cart一个子目录里吧,设置好固定连接等这个文件/includes/templates/template_default/templates/tpl_product_ ...

  6. Codeforces Round #363 (Div. 2)D. Fix a Tree(并查集)

    D. Fix a Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  7. discuz 添加板块失败解决办法

    最近把服务器环境升了下级,发现discuz后台添加栏目添加不了了,数据库没变,源代码没变,就突然添加不了了.刚开始添加1个板块成功了,再添加就怎么也添不进去了.只是页面刷新了一下,啥提示没有. 经过一 ...

  8. zf-监察系统的左侧菜单树的表

    Sys_Right 这个表

  9. gen_grant_exec.sql

    set echo off feedback off verify off pagesize 0 linesize 120 define v_grantee                 = & ...

  10. centos 7.1搭建docker本地私有仓库返回500错误

    之前有一篇写到在ubuntu14.04系统上安装私有仓库,遇到了两个问题,本次在centos7上遇到了另外一个问题. 安装完仓库并运行registry镜像之后发现push和pull操作都会返回一个50 ...