php mysql 框架 php5.2_php项目框架搭建(二)【数据库篇】Result

本文为firedragonpzy原创,转载务必在明显处注明:

转载自【Softeware MyZone】原文链接:http://www.firedragonpzy.com.cn/index.php/archives/2309

本文主要是围绕这数据库操作的返回的结果集进行封装处理的。以后在使用的时候,有关数据库操作的,包括结果集的信息,操作成功失败的信息,分页的信息,都在这里得到了一一的体现,详细如下:

private $success = true;//处理成功标志

private $info = "";//处理结果信息

private $pageNum = 1;//当前页码

private $pageSize = 0;//每页大小

private $pageCount = 1;//页码总数

private $recCount = 0;//记录总数

private $rows = null;//返回的页面结果集

private $data = null;//其它数据

/**

* @return the $success

*/

public function getSuccess() {

return $this->success;

}

/**

* @return the $info

*/

public function getInfo() {

return $this->info;

}

/**

* @return the $pageNum

*/

public function getPageNum() {

return $this->pageNum;

}

/**

* @return the $pageSize

*/

public function getPageSize() {

return $this->pageSize;

}

/**

* @return the $pageCount

*/

public function getPageCount() {

return $this->pageCount;

}

/**

* @return the $recCount

*/

public function getRecCount() {

return $this->recCount;

}

/**

* @return the $rows

*/

public function getRows() {

return $this->rows;

}

/**

* @return the $data

*/

public function getData() {

return $this->data;

}

/**

* @param boolean $success

*/

public function setSuccess($success) {

$this->success = $success;

}

/**

* @param string $info

*/

public function setInfo($info) {

$this->info = $info;

}

/**

* @param number $pageNum

*/

public function setPageNum($pageNum) {

$this->pageNum = $pageNum;

}

/**

* @param number $pageSize

*/

public function setPageSize($pageSize) {

$this->pageSize = $pageSize;

}

/**

* @param number $pageCount

*/

public function setPageCount($pageCount) {

$this->pageCount = $pageCount;

}

/**

* @param number $recCount

*/

public function setRecCount($recCount) {

$this->recCount = $recCount;

}

/**

* @param NULL $rows

*/

public function setRows($rows) {

$this->rows = $rows;

}

/**

* @param NULL $data

*/

public function setData($data) {

$this->data = $data;

}

1)以上是最基本的,其中$rows主要存取数据库操作的结果集。其中返回信息成功与否用$success,返回的存储信息用$info。想要一起设置,则可以调用下述方法:

/**

* 设置处理结果信息

* @author firedragonpzy

* @param unknown_type $success

* @param unknown_type $info

*/

public function setMessage($success,$info)

{

$this->setSuccess($success);

$this->setInfo($info);

}

2)之前也讲到过把分页的信息也封装到了result中,详细如下:

/**

* 设计分页的相关信息

* @author firedragonpzy

* @param unknown_type $pageNum

* @param unknown_type $pageSize

* @param unknown_type $recCount

*/

public function setPage($pageNum,$pageSize,$recCount)

{

if ($pageNum <= 0)

{

$pageNum = 1;

}

$this->pageNum = $pageNum;

if ($pageSize <= 0)

{

$pageSize = Page::$MAX_PAGE_SIZE;

}

$this->pageSize = $pageSize;

$this->recCount = $recCount;

$this->pageCount = (int)(($recCount + $pageSize -1)/$pageSize);

if ($pageNum > $this->pageCount)

{

$this->pageNum = $this->pageCount;

}

}

Tags: php, zf

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值