实现链式操作的核心方法就是 : return $this;
下面是例子:/** * 设置是否严格检查字段名 * @access public * @param bool $strict 是否严格检查字段 * @return $this */ public function strict(bool $strict = true) { $this->options['strict'] = $strict; return $this; } /** * 设置自增序列名 * @access public * @param string $sequence 自增序列名 * @return $this */ public function sequence(string $sequence = null) { $this->options['sequence'] = $sequence; return $this; } /** * 设置JSON字段信息 * @access public * @param array $json JSON字段 * @param bool $assoc 是否取出数组 * @return $this */ public function json(array $json = [], bool $assoc = false) { $this->options['json'] = $json; $this->options['json_assoc'] = $assoc; return $this; }
最后修改:2021 年 06 月 20 日 05 : 37 PM
© 允许规范转载