对于编成方面,自己确实是弱的很,但却不能因为这个而剥夺了我喜欢的权利。PHP5出了也有一段时间了,早就听说在OO方便增强了很多,试了一下还真的是不错的。但自己对OO却知之甚少,只粗略的知道了一点皮毛而已。下载这个是我自己在用的一个见得数据处理模型,因为本来就知道的不错,所以也就尽可能的简单了,希望大家斧正!
这里是一个简单的应用,只是来给大家演示一下是如何应用的,至于文档嘛,本来做得就不好,而且也懒得写了,还是看看实例来的方便些!
<?php
//
// +----------------------------------------------------------------------+
// | PHP version 5.0 |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004 |
// | Moocky Mark(木目子). |
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Authors: Moocky Mark |
// | QQ: 44333697 |
// | MSN: moocky@hotmail.com |
// | Email: moocky@moocky.net |
// +----------------------------------------------------------------------+
//
//
/**
* 使用方法范例
*
*
* @version v 1.0
* @access Note
*/
class TestData extends abstractData{
private $sTable ='TestData';
public function __construct(&$conn)
{
$this->_oConn = $conn;
}
/**
* 增加记录
* @params $maInfo:Array;
* @return Int;
*/
public function add($maInfo)
{
$maInfo["intime"]=date('Y-m-d H:i:s');
$iID = $this->insert($this->sTable, $maInfo);
if($iID)
{
return $iID;
}
return 0;
}
/**
* 更新记录
* @params $maInfo:Array;
* @params $miID:Int;
* @return Boolean;
*/
public function modify($maInfo, $miID)
{
if($this->update($this->sTable, $maInfo, $where))
{
return true;
}
return false;
}
/**
* 得到记录内容
* @params Int;
* @return Array;
*/
public function get($miID)
{
$sSQL = sprintf("select `topic`,`content`,`intime`,`hits` from `%s` where `note_id`='%s'",
$this->sTable,$miID);
$this->_oConn->executeQuery();
while($this->_oConn->next())
{
$D["topic"] =$this->_oConn->getString("topic");
$D["content"] =$this->_oConn->getString("content");
$D["intime"] =$this->_oConn->getString("intime");
}
return $D;
}
/**
* 统计公告
* @params $Where :String;
* @return Int;
*/
public function getCount($mWhere="")
{
if(is_array($mWhere)){
$where = "where ".$this->getWhere($mWhere);
}elseif($mWhere!=""){
$where = "where ".$mWhere;
}
$sSQL = sprintf("select count(1) as `total` from `%s` %s",
$this->sTable,$where);
$this->_oConn->executeQuery($sSQL);
if($this->_oConn->next())
{
return $this->_oConn->getString("total");
}
return 0;
}
/**
* 列出公告
* @params $Where: String;
* @params $Order: String;
* @params $Limit: Int;
* @params $RowCount: Int;
* @return Array;
*/
public function getList($mWhere="",$Order="",$Limit=0,$RowCount=20)
{
if(is_array($mWhere)){
$where = "where ".$this->getWhere($mWhere);
}elseif($mWhere!=""){
$where = "where ".$mWhere;
}
if($Order=="")
{
$Order="`intime` desc";
}
$sSQL=sprintf("select `id`,`topic`,`intime` from `%s` %s order by %s limit %s,%s",
$$this->sTable,
$where,
$Order,
$Limit,
$RowCount);
$this->_oConn->executeQuery($sSQL);
$i = 0;
while($this->_oConn->next())
{
$D[$i]["note_id"] =$this->_oConn->getString("note_id");
$D[$i]["topic"] =$this->_oConn->getString("topic");
$D[$i]["intime"] =$this->_oConn->getString("intime");
$i++;
}
return $D;
}
/**
* 删除文章
* @params Int;
* @return Int;
*/
public function delete($miID)
{
return $this->del($this->sTable,"`id`='$miID'");
}
}
?>




