/** * 准备数据库链接实例 * * @param \CatLib\Database\Connections\Connection $connection * @return \CatLib\Database\Connections\Connection */ protected function prepare(Connection $connection) { if (isset($this->app['env']['database']['fetch'])) { $connection->setFetchMode($this->app['env']['database']['fetch']); } if ($this->app->isExists('events')) { $connection->setEventDispatcher($this->app['events']); } $connection->setReconnector(function ($connection) { $this->reconnect($connection->getName()); }); return $connection; }