码迷,mamicode.com
首页 > Web开发 > 详细

php链式操作的实现

时间:2016-12-24 23:05:48      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:;;   ack   title   esc   业务   tab   mil   div   his   

在每个函数实现业务逻辑后,使用return $this;
<?php
namespace IMooc;

class Database
{
function where($where)
{
return $this;
}

function order($order)
{
return $this;
}

function limit($limit)
{
return $this;
}
}

$db = new IMooc\Database();
$db->where("id=1")->where("name=2")->order("id desc")->limit(10);
//$db->where("id=1");
//$db->where("name=2");
//$db->order("id desc");
//$db->limit(10);




php链式操作的实现

标签:;;   ack   title   esc   业务   tab   mil   div   his   

原文地址:http://www.cnblogs.com/phonecom/p/c658305e62feef500f8fe08b6b6571a6.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!