如果光是链式调用的话,在每个方法return $this就行
但是不明白如果是这样
Db::table('**')->where('***','***')->order('***')->find('**');
想这种应该怎么实现
如果光是链式调用的话,在每个方法return $this就行
但是不明白如果是这样
Db::table('**')->where('***','***')->order('***')->find('**');
想这种应该怎么实现
简单示例:
<?php
class Db
{
public $table;
public $a;
public $b;
public static function table($table)
{
$db = new static;
$db->table = $table;
return $db;
}
public function where($a, $b)
{
$this->a = $a;
$this->b = $b;
return $this;
}
}
Db::table('abc')->where('a', 'b');
2 回答1.3k 阅读✓ 已解决
1 回答988 阅读✓ 已解决
2 回答849 阅读✓ 已解决
1 回答1k 阅读✓ 已解决
2 回答906 阅读
1 回答891 阅读
1 回答820 阅读