$sb->where()->order->limit()->find();
<?php /** * Created by PhpStorm. * User: chen * Date: 2016/11/30 * Time: 16:52 */ namespace Imooc; class Database { public function where($where) { //核心 方法返回自己 return $this; } public function order($order) { //核心 方法返回自己 return $this; } public function limit($limit) { //核心 方法返回自己 return $this; } }
//链式操作 $db = new \Imooc\Database(); $db->where('id = 1')->where('name=chenshaui')->limit(10);