php 链式操作的实现 学习记录

php 面向对象中实现链式操作的关键部分:调用的方法中返回当前对象 ,从而实现链式操作

<?php
namespace commom;

class db
{
    public function where($where){
        return $this;
    }

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

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

    }
}

这样就可以实现链式操作

<?php
    $db  = new DataBase();
    $db->where()->order()->select();
?>

转: https://www.cnblogs.com/lilili/p/5145963.html

原文地址:https://www.cnblogs.com/fps2tao/p/9687507.html