) { $condition = $condition ? ' Where ' . $condition : NULL; if ($debug) { echo "SELECT $columnName FROM $table $condition"; } else { $this->query("SELECT $columnName FROM $table $condition"); } } //简化删除 del public function delete($table, $condition, $url = '') { if ($this->query("DELETE FROM $table WHERE $condition")) { if (!empty ($url)) $this->Get_admin_msg($url, '删除成功!'); } } //简化插入 insert public function insert($table, $columnName, $value, $url = '') { if ($this->query("INSERT INTO $table ($columnName) VALUES ($value)")) { if (!empty ($url)) $this->Get_admin_msg($url, '添加成功!'); } } //简化修改 update public function update($table, $mod_content, $condition, $url = '') { //echo "UPDATE $table SET $mod_content WHERE $condition"; exit(); if ($this->query("UPDATE $table SET $mod_content WHERE $condition")) { if (!empty ($url)) $this->Get_admin_msg($url);
} }
public function insert_id() { return mysql_insert_id(); } //指向确定的一条数据记录 public function db_data_seek($id) { if ($id > 0) { $id = $id -1; } if (!@ mysql_data_seek($this->result, $id)) { $this->show_error("SQL 语句有误:", "指定的数据为空"); } return $this->result; } // 根据 select 查询结果计算结果集条数 public function db_num_rows() { if ($this->result == null) { if ($this->show_error) { $this->show_error("SQL 语句错误", "暂时为空,没有任何内容!"); } } else { return mysql_num_rows($this->result); } } // 根据 insert,update,delete 执行结果取得影响行数 public function db_affected_rows() { return mysql_affected_rows(); } //输出显示 sql 语句 public function show_error($message = "", $sql = "") { if (!$sql) { echo "
" . $message . ""; echo "
"; } else { echo "