mysqli面向对象进行dql dml 查询
2015-01-05 23:12
204 查看
<?php /** * 函数名称:sqlHelper.class.php * 函数功能:mysqli面向对象进行dql dml 查询 * 函数作者:张真贵 * 创建时间:2015-01-05 * 修改时间: */ class SqlHelper { private $mysqli; private static $host = 'localhost'; private static $root = "root"; private static $password = ""; private static $dbname = "test"; public function __construct() { # code... $this->mysqli = new mysqli(self::$host,self::$root,self::$password,self::$dbname); if ($this->mysqli->connect_error) { # code... die("连接失败".$this->mysqli->connect_error); } $this->mysqli->query("set names utf8"); } public function execute_dql($sql){ $res = $this->mysqli->query($sql) or die("dql失败".$this->mysqli->error); return $res; } public function execute_dml($sql){ $res = $this->mysqli->query($sql) or die("dml失败".$this->mysqli->error); if (!$res) { # code...失败 return 0; }elseif ($this->mysqli->fetch_rows > 0) { # code...成功 return 1; }else{ # code...没有影响行数 return 2; } } } ?>
相关文章推荐
- php-mysqli-面向对象查询 连接mysqli
- 将面向对象进行到底---2004
- hiernate 中联合查询,得到的list是一个对象数组,这样需要进行适当处理来取值。
- Ruby on Rails,使用where方法对持久化对象进行条件查询
- 【面向对象程序设计常见面试题】对对象成员进行初始化的次序是什么?(11)
- ibatis教程_查询所有的对象(对student进行增删改查)
- mysqli面向对象高效连接数据库
- SharePoint服务器端对象模型 之 使用CAML进行数据查询
- JavaScript面向对象实例——创建日志调试对象来代替alert函数进行调试
- 【面向对象程序设计常见面试题】类中成员变量怎么进行初始化?(11)
- 使用面向对象工具进行着面向过程的开发
- 面向对象分析设计中如何进行数据库设计
- .NET/C#中对对象集合进行查询的方法 以及相关的 Predicate<T> 及 Action<T> 的用法
- Ruby on Rails,使用where方法对持久化对象进行条件查询
- 转载:将面向对象进行到底...
- 面向对象思想的头脑风暴(三)-使用接口进行解耦
- .NET/C#中对对象集合进行查询的方法 以及相关的 Predicate<T> 及 Action<T> 的用法
- php MySQLi部分函数(面向对象和过程)
- 10-hibernate实战 面向对象方式查询Criteria
- 面向对象上机题-成绩查询