php的鏈式操做的理解和應用

php鏈式操做:相似以下實現 $db->where()->limit()->order(); 不使用鏈式調用時的代碼格式以下:php

<?php  
namespace Database;  
  
class Database  
{  
    public function where($where)  
    {  
        return $this;  
    }  
    public function order($order)  
    {  
        return $this;  
    }  
    public function limit($limit)  
    {  
        return $this;  
    }  
      
}

代碼調用以下:this

<pre name="code" class="php">//代碼調用  
$db = new Database\Database();  
$db->where('...')->order('...')->limit('...');
相關文章
相關標籤/搜索