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:----Kf8b5NXJSgM4s/33U1QsBXnJHIhBUeVtS36o8m2MmjiM5gEv+rpEuXhGL92abdEUuMM0t4qvAdiBqMw39lShOTeqNXXI0UOdqDzSIecokFnYjmMvsakRp0qXVW8U+s/iHo99YgUD93YFRlOOvMzUcSR85cDamIv+xfgf6hSjcyoM8lbz4iHh1KNSzHKawKRI9FN9NUqCSdATlp3lj49Oh2/b59N4Qgv4UDCBMqCq0AlHcXx0L9TO6ijDF5UhontKD3Ier6n6hVu/eKa/QYWlXb6nW376LcH77C8EGFK3QuCZSk0aOgpRASMvUHq64/uJr2TYogwz5N0aCMCLFQ3VTpreWEAuA54Cr5k/MT+J0pU2p+W+PLz5oNDXZyXJtmunVXigxp0eNUiJpZKo/AiD664B0hci0Pnkxhmsvf1fTMn6Z1vATP45megI0SyN4CTu+nsGSdJSzuNXEZZq9y+I4LyImuFeTIARWzbDq33c4g9A+saVAMPRCDcONtykav1N/MqV1xRmND/y3m2DNCvVQqnBbEq/G3sCnSx1knFZroYMQN8PBUgCDE9h2X2WwM+mCa4qUEzUUQWAm7Hcf6a/0Cau0A3OszPlt+dwV2BVaQH0UwHs3KwavoEhWBKnHEV41ykyk4vkEqSXXvwfkM3jb02yixF314PnRgE3tlThdq8=----ATTACHMENT:----OTk0NTkzNDI3NzcyMzA2NiA4NTExMTI4NDc1ODE2MDA4IDEwNTM0NjY4Mzg5OTc5MDI=