php链式操作的实现

$db = new IMooc\Database();
$db->where(")->where("name=2")->order("id desc")->limit(10);
//$db->where(");
//$db->where("name=2");
//$db->order("id desc");
//$db->limit(10);
<?php
namespace IMooc;
class Database
{
function where($where)
{
return $this;
}
function order($order)
{
return $this;
}
function limit($limit)
{
return $this;
}
}

在每个函数实现业务逻辑后,使用return $this;

来自为知笔记(Wiz)