MySql操作类
最近写了一个简单的Mysql操作类,拿出来和大家分享一下,还请各位高手指正一下析构函数的用法:
<?php
/*
* Created on 2010-5-25
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*
* class mysql
* made by S71ENCE
*/
class mysql
{
private $host;//主机名
private $name;//用户名
private $pwd;//密码
private $dataBase;//数据库名
private $coding;//编码
//初始化
function __construct($host,$name,$pwd,$dataBase,$coding)
{
$this->host=$host;
$this->name=$name;
$this->pwd=$pwd;
$this->dataBase=$dataBase;
$this->coding=$coding;
$this->connect();//初始化连接
}
/*********************************************************************************************
* 数据库
* 基本方法
********************************************************************************************/
//数据库连接
function connect()
{
$link=mysql_connect($this->host,$this->name,$this->pwd) or die($this-error());
mysql_select_db($this->dataBase,$link) or die("无法连接数据库".$this->dataBase);
mysql_query("set names '$this->coding'");
}
//错误信息
function error()
{
return mysql_error
相关文档:
用mysql_query,mysql_fetch_array()后应该要
free_result().function count_admin($where = '')
{
if($where) $where = " WHERE $where";
$result = $this->db->get_one("SELECT count(*) as num from $this->table_admin_role $where");
return $result['num'];
} ......
1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引。
2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎
放弃使用索引而进行全表扫描,如:
select id from t where num is null
可以在num上设置
默认值0,确保表中num列没有null值,然后这
样查询:
sel ......
MYSQL和ORACLE的一些操作区别
有很多应用项目, 刚起步的时候用MYSQL数据库基本上能实现各种功能需求,随着应用用户的增多,数据量的增加,MYSQL渐渐地出现不堪重负的情况:连接很慢甚至宕机,于是就有把数据从MYSQL迁到ORACLE的需求,应用程序也要相应做一些修改。本人总结出以下几点注意事项,希望对大家有所帮助。
1.自 ......
MySQL数据库日志
select日志
slow select日志
变更日志
二进制变更日志(binlog)
告警日志
错误日志。
可以在my.cnf中配置
参数
说明
log
文本select日志,记下所有的MySQL的命令操作,
log-update
文本变更日志
log-bin
这个都知道了,数据库复制的时候必备
binlog_cache_size
临时存放某次事务的SQL ......
下面我给大家介绍几种在mysql数据库中修改root密码的方法
方法一:
原始密码是 ckh
mysql -uroot -pckh
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7 to server version: 5.0.22-community-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
my ......