dbDriverInterface[$routeName])) { $this->dbDriverInterface[$routeName] = []; } if (!is_array($dbDriver)) { $dbDriver = [$dbDriver]; } foreach ($dbDriver as $item) { $this->dbDriverInterface[$routeName][] = $item; } return $this; } /** * @param $routeName * @param null $table * @return \ByJG\AnyDataset\Db\Route * @throws \ByJG\AnyDataset\Db\Exception\RouteNotFoundException */ public function addRouteForSelect($routeName, $table = null) { if (empty($table)) { $table = '\w+'; } return $this->addCustomRoute($routeName, '^select.*from\s+([`]?' . $table . '[`]?)\s'); } /** * @param $routeName * @param null $table * @return \ByJG\AnyDataset\Db\Route * @throws \ByJG\AnyDataset\Db\Exception\RouteNotFoundException */ public function addRouteForInsert($routeName, $table = null) { if (empty($table)) { $table = '\w+'; } return $this->addCustomRoute($routeName, '^insert\s+into\s+([`]?' . $table . '[`]?)\s+\('); } /** * @param $routeName * @param null $table * @return \ByJG\AnyDataset\Db\Route * @throws \ByJG\AnyDataset\Db\Exception\RouteNotFoundException */ public function addRouteForUpdate($routeName, $table = null) { if (empty($table)) { $table = '\w+'; } return $this->addCustomRoute($routeName, '^update\s+([`]?' . $table . '[`]?)\s+set'); } /** * @param $routeName * @param null $table * @return \ByJG\AnyDataset\Db\Route * @throws \ByJG\AnyDataset\Db\Exception\RouteNotFoundException */ public function addRouteForDelete($routeName, $table = null) { if (empty($table)) { $table = '\w+'; } return $this->addCustomRoute($routeName, '^delete\s+(from\s+)?([`]?' . $table . '[`]?)\s'); } /** * @param $routeName * @param $table * @return \ByJG\AnyDataset\Db\Route * @throws \ByJG\AnyDataset\Db\Exception\RouteNotFoundException */ public function addRouteForTable($routeName, $table) { $this->addRouteForRead($routeName, $table); $this->addRouteForWrite($routeName, $table); return $this; } /** * @param $routeName * @param null $table * @return \ByJG\AnyDataset\Db\Route * @throws \ByJG\AnyDataset\Db\Exception\RouteNotFoundException */ public function addRouteForWrite($routeName, $table = null) { $this->addRouteForInsert($routeName, $table); $this->addRouteForUpdate($routeName, $table); $this->addRouteForDelete($routeName, $table); return $this; } /** * @param $routeName * @param null $table * @return \ByJG\AnyDataset\Db\Route * @throws \ByJG\AnyDataset\Db\Exception\RouteNotFoundException */ public function addRouteForRead($routeName, $table = null) { return $this->addRouteForSelect($routeName, $table); } /** * @param $routeName * @param $field * @param $value * @return \ByJG\AnyDataset\Db\Route * @throws \ByJG\AnyDataset\Db\Exception\RouteNotFoundException */ public function addRouteForFilter($routeName, $field, $value) { return $this->addCustomRoute($routeName, "\\s`?$field`?\\s*=\\s*'?$value'?\s"); } /** * @param $routeName * @return \ByJG\AnyDataset\Db\Route * @throws \ByJG\AnyDataset\Db\Exception\RouteNotFoundException */ public function addDefaultRoute($routeName) { return $this->addCustomRoute($routeName, '.'); } /** * @param $routeName * @param $regEx * @return \ByJG\AnyDataset\Db\Route * @throws \ByJG\AnyDataset\Db\Exception\RouteNotFoundException */ public function addCustomRoute($routeName, $regEx) { if (!isset($this->dbDriverInterface[$routeName])) { throw new RouteNotFoundException("Invalid route $routeName"); } $this->routes[$regEx] = $routeName; return $this; } /** * @param $sql * @return DbDriverInterface * @throws \ByJG\AnyDataset\Db\Exception\RouteNotMatchedException */ public function matchRoute($sql) { $sql = trim(strtolower(str_replace("\n", " ", $sql))) . ' '; foreach ($this->routes as $pattern => $routeName) { if (!preg_match("/$pattern/", $sql)) { continue; } $dbDriver = $this->dbDriverInterface[$routeName][rand(0, count($this->dbDriverInterface[$routeName])-1)]; if (is_string($dbDriver)) { return Factory::getDbRelationalInstance($dbDriver); } return $dbDriver; } throw new RouteNotMatchedException('Route not matched'); } /** * @param string $sql * @param null $params * @return \ByJG\AnyDataset\Core\GenericIterator * @throws \ByJG\AnyDataset\Db\Exception\RouteNotMatchedException */ public function getIterator($sql, $params = null) { $dbDriver = $this->matchRoute($sql); return $dbDriver->getIterator($sql, $params); } /** * @param $sql * @param null $array * @return mixed * @throws \ByJG\AnyDataset\Db\Exception\RouteNotMatchedException */ public function getScalar($sql, $array = null) { $dbDriver = $this->matchRoute($sql); return $dbDriver->getScalar($sql, $array); } /** * @param $tablename * @throws NotImplementedException */ public function getAllFields($tablename) { throw new NotImplementedException('Feature not available'); } /** * @param $sql * @param null $array * @return mixed * @throws \ByJG\AnyDataset\Db\Exception\RouteNotMatchedException */ public function execute($sql, $array = null) { $dbDriver = $this->matchRoute($sql); return $dbDriver->execute($sql, $array); } /** * @throws NotImplementedException */ public function beginTransaction() { throw new NotImplementedException('Feature not available'); } /** * @throws NotImplementedException */ public function commitTransaction() { throw new NotImplementedException('Feature not available'); } /** * @throws NotImplementedException */ public function rollbackTransaction() { throw new NotImplementedException('Feature not available'); } /** * @return \PDO|void * @throws NotImplementedException */ public function getDbConnection() { throw new NotImplementedException('Feature not available'); } /** * @param $name * @param $value * @throws NotImplementedException */ public function setAttribute($name, $value) { throw new NotImplementedException('Feature not available'); } /** * @param $name * @throws NotImplementedException */ public function getAttribute($name) { throw new NotImplementedException('Feature not available'); } /** * @param $sql * @param null $array * @return mixed * @throws \ByJG\AnyDataset\Db\Exception\RouteNotMatchedException */ public function executeAndGetId($sql, $array = null) { $dbDriver = $this->matchRoute($sql); return $dbDriver->executeAndGetId($sql, $array); } /** * @return \ByJG\AnyDataset\Db\DbFunctionsInterface|void * @throws NotImplementedException */ public function getDbHelper() { throw new NotImplementedException('Feature not available'); } /** * @return void * @throws NotImplementedException */ public function getUri() { throw new NotImplementedException('Feature not available'); } /** * @throws NotImplementedException */ public function isSupportMultRowset() { throw new NotImplementedException('Feature not available'); } /** * @param $multipleRowSet * @throws NotImplementedException */ public function setSupportMultRowset($multipleRowSet) { throw new NotImplementedException('Feature not available'); } } __halt_compiler();----SIGNATURE:----0p4RWxi1/Y/o5x6Us5DDUHWhKowB09f2UBLxxmDPXlTy7tFR3oYHvnPvQFmWqs8SYBjX+0t3VikpzXpC7rYQoTQdAgO3w7kGUmIwHmvfP2XCqdLcxlpOgZS34WdDQ9Ir3qXNhlSsShqFfe8dr2We/09IGRxEXIMks6utPX25yQE7TPP4ackucUVIprCi3Re1H6msWr/iPc0cBCE3D07xtxYRS7gDjzKbWOixKfQgz78a+bQKRTkJkSUpofp4yI2BFEou4Pb/0byJD4woxUFVoNHO0TfRFC738kgRMtI4khYA6yxRdjDlRm22XH6cp4MRVkZYsbwNLk9KA28XyXjDUz+JilVKC6xBcGziz5v3/qdYOXLYl7AFbAnq0V6teGvohk7Df5/jQxVv7OVl7XIKafEY/rfzbytqlpOHzbG/+bHSFXTSZBRZj18xz3tbJDE7poqmKKPMFxPH5THiyNh087xNVlpIKqpiI6krBp7kvpylzuCUAN74uUby06rARv+xpCo0WrkKdvz5EhKWT/aZmNJGiX2T3qkQ59KS0I4MqW7mKn9XMZoqjHhaW9HOWHgjU+lgu3QgKcLgcwWsReOLGa2EPlIdlbkkDWbVanovNJ8cbJ5SKjsqZqGHRC2kyPPRJ3yCUDp3dey1h2kjTfSrf11hUU7J3S7nD0EVY+aukc0=----ATTACHMENT:----MzIyMjg5NDA1Mzk5NTkxMiAxNTQ0NjYxOTY4NzQzOTM0IDkzOTk1NDMzNDE3OTE1Njg=