易截截图软件、单文件、免安装、纯绿色、仅160KB

PHP不变的一些经典类

 MYSQL,分页类是写PHP代码最常用的几个类。
今天看PHP100的视频,越用越发现里面两个类好强大,虽然感觉还是有局限性,但是它的写法已经很成熟了。
一个是MYSQL,一个是分页类。
MYSQL:
<?php
class mysql {
private $db_host; //数据库主机
private $db_user; //数据库用户名
private $db_pwd; //数据库用户名密码
private $db_database; //数据库名
private $conn; //数据库连接标识;
private $result; //执行query命令的结果资源标识
private $sql; //sql执行语句
private $row; //返回的条目数
private $coding; //数据库编码,GBK,UTF8,gb2312
private $bulletin = true; //是否开启错误记录
private $show_error = true; //测试阶段,显示所有错误,具有安全隐患,默认关闭
private $is_error = false; //发现错误是否立即终止,默认true,建议不启用,因为当有问题时用户什么也看不到是很苦恼的
/*构造函数*/
public function __construct($db_host, $db_user, $db_pwd, $db_database, $conn, $coding) {
$this->db_host = $db_host;
$this->db_user = $db_user;
$this->db_pwd = $db_pwd;
$this->db_database = $db_database;
$this->conn = $conn;
$this->coding = $coding;
$this->connect();
}
/*数据库连接*/
public function connect() {
if ($this->conn == "pconn") {
//永久链接
$this->conn = mysql_pconnect($this->db_host, $this->db_user, $this->db_pwd);
} else {
//即使链接
$this->conn = mysql_connect($this->db_host, $this->db_user, $this->db_pwd);
}
if (!mysql_select_db($this->db_database, $this->conn)) {
if ($this->show_error) {
$this->show_error("数据库不可用:", $this->db_database);
}
}
mysql_query("SET NAMES $this->coding");
}
/*数据库执行语句,可执行查询添加修改删除等任何sql语句*/
public function query($sql) {
if ($sql == "") {
$this->show_error("SQL语句错误:", "SQL查询语句为空");
}
$this->sql = $sql;
$result = mysql_query($this->sql, $this->conn);
if (!$result) {
//调试中使用,sql语句出错时会自动打印出来
if ($this->show_


相关文档:

PHP 5.2.11安装

#找到:
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gz ......

PHP 几个路径函数

 //
dirname()
// Returns directory name component of path
basename()
// Returns filename component of path
pathinfo()
// Returns information about a file path;
// pathinfo() returns an associative array containing information about path .
parse_url()
// Parse a URL and return its comp ......

php总结(2)

【对象】-->分析的结果-->【原型】-->【类】 业务是对象与对象的交互 实体 非实体 更清晰的分析对象间的关系 行为用来描述原型 属性对应特征 接口是对一类原型或多类原型某一方面方法的规范 实例-对象的的具体,类的实例化的结果 面向对象的3个步骤 OOA--理清逻辑,找出原型 【对象】-->【原型】 OOD--根据原型,解 ......

php总结(4)

apache 动态编译 编译成so 静态编译 C 效率高5% 先完全动态编译,确定需要的 静态编译 合理使用会话 尽可能少的加载外部文件 尽可能少的占用外部资源 lazyload 迟连接早释放 变量应尽可能的保持一种类型 改变变量类型的时候,只会自动增所占内存 不会减少 如int->float  占空间变大 float->int 不会变小 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号