在每个函数实现业务逻辑后,使用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);
原文:http://www.cnblogs.com/phonecom/p/c658305e62feef500f8fe08b6b6571a6.html