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

 

posted @ 2018-09-21 17:11  与f  阅读(248)  评论(0)    收藏  举报