The wind is coming.fox
Because the sub-table is used, the method needs to be rewritten
Error report:
Declaration of ..... should be compatible with .....
Please use the following method to solve it
class Model { /**设置分表名 * @param int $tableNum UID或表序号 * @param int $num 位数 * @return $this */ public function tableSplit($tableNum=0,$num=2){ $this->table($this->getTableNameSplit($tableNum,$num)); return $this; } } class StockFlowModel extends Model { /**设置分表名 * @param int $tableNum UID或表序号 * @param int $num * @return $this */ public function tableSplit($tableNum=0,$num=4) { if(empty($tableNum)){ $tableNum=date_time_format(DATE_TIME, 'ym'); } parent::tableSplit($tableNum, $num); return $this; } }
When overriding methods, the same conventions as the parent class methods, parameter names must be consistent, and attribute coverage must also be consistent.
When calling the parent class method, use the parent:: method to call
Copyright statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above has introduced the PHP object-oriented method rewriting, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.