|array */ protected array $dbDriverInterface = []; /** @var string[] */ protected array $routes; public static function schema() { return null; } /** * Route constructor. */ public function __construct() { } /** * @param string $routeName * @param string|DbDriverInterface|DbDriverInterface[]|string[] $dbDriver * @return $this */ public function addDbDriverInterface(string $routeName, array|string|DbDriverInterface $dbDriver): static { if (!isset($this->dbDriverInterface[$routeName])) { $this->dbDriverInterface[$routeName] = []; } if (!is_array($dbDriver)) { $dbDriver = [$dbDriver]; } foreach ($dbDriver as $item) { if (!is_string($item) && !($item instanceof DbDriverInterface)) { throw new InvalidArgumentException('Invalid dbDriver'); } $this->dbDriverInterface[$routeName][] = $item; } return $this; } /** * @param string $routeName * @param string|null $table * @return static * @throws RouteNotFoundException */ public function addRouteForSelect(string $routeName, ?string $table = null): static { if (empty($table)) { $table = '\w+'; } return $this->addCustomRoute($routeName, '^select.*from\s+([`]?' . $table . '[`]?)\s'); } /** * @param string $routeName * @param string|null $table * @return static * @throws RouteNotFoundException */ public function addRouteForInsert(string $routeName, ?string $table = null): static { if (empty($table)) { $table = '\w+'; } return $this->addCustomRoute($routeName, '^insert\s+into\s+([`]?' . $table . '[`]?)\s+\('); } /** * @param string $routeName * @param string|null $table * @return static * @throws RouteNotFoundException */ public function addRouteForUpdate(string $routeName, ?string $table = null): static { if (empty($table)) { $table = '\w+'; } return $this->addCustomRoute($routeName, '^update\s+([`]?' . $table . '[`]?)\s+set'); } /** * @param string $routeName * @param string|null $table * @return static * @throws RouteNotFoundException */ public function addRouteForDelete(string $routeName, ?string $table = null): static { if (empty($table)) { $table = '\w+'; } return $this->addCustomRoute($routeName, '^delete\s+(from\s+)?([`]?' . $table . '[`]?)\s'); } /** * @param string $routeName * @param string|null $table * @return static * @throws RouteNotFoundException */ public function addRouteForTable(string $routeName, ?string $table = null): static { $this->addRouteForRead($routeName, $table); $this->addRouteForWrite($routeName, $table); return $this; } /** * @param string $routeName * @param string|null $table * @return static * @throws RouteNotFoundException */ public function addRouteForWrite(string $routeName, ?string $table = null): static { $this->addRouteForInsert($routeName, $table); $this->addRouteForUpdate($routeName, $table); $this->addRouteForDelete($routeName, $table); return $this; } /** * @param string $routeName * @param string|null $table * @return static * @throws RouteNotFoundException */ public function addRouteForRead(string $routeName, ?string $table = null): static { return $this->addRouteForSelect($routeName, $table); } /** * @param string $routeName * @param string $field * @param string $value * @return static * @throws RouteNotFoundException */ public function addRouteForFilter(string $routeName, string $field, string $value): static { return $this->addCustomRoute($routeName, "\s`?$field`?\s*=\s*'?$value'?\s"); } /** * @param string $routeName * @return static * @throws RouteNotFoundException */ public function addDefaultRoute(string $routeName): static { return $this->addCustomRoute($routeName, '.'); } /** * @param string $routeName * @param string $regEx * @return static * @throws RouteNotFoundException */ public function addCustomRoute(string $routeName, string $regEx): static { if (!isset($this->dbDriverInterface[$routeName])) { throw new RouteNotFoundException("Invalid route $routeName"); } $this->routes[$regEx] = $routeName; return $this; } /** * @param string $sql * @return DbDriverInterface * @throws RouteNotMatchedException */ public function matchRoute(string $sql): DbDriverInterface { $sql = trim(strtolower(str_replace("\n", " ", $sql))) . ' '; foreach ($this->routes as $pattern => $routeName) { if (!preg_match("/$pattern/", $sql)) { continue; } $item = rand(0, count($this->dbDriverInterface[$routeName])-1); $dbDriver = $this->dbDriverInterface[$routeName][$item]; if (is_string($dbDriver)) { $dbDriver = Factory::getDbInstance($dbDriver); $this->dbDriverInterface[$routeName][$item] = $dbDriver; } return $dbDriver; } throw new RouteNotMatchedException('Route not matched'); } public function prepareStatement(string $sql, ?array $params = null, ?array &$cacheInfo = []): mixed { // TODO: Implement prepareStatement() method. return null; } public function executeCursor(mixed $statement): void { // TODO: Implement executeCursor() method. } /** * @param string $sql * @param array|null $params * @param CacheInterface|null $cache * @param int|DateInterval $ttl * @param int $preFetch * @return GenericIterator * @throws RouteNotMatchedException */ public function getIterator( mixed $sql, ?array $params = null, ?CacheInterface $cache = null, DateInterval|int $ttl = 60, int $preFetch = 0, ): GenericIterator { $dbDriver = $this->matchRoute($sql); return $dbDriver->getIterator($sql, $params, $cache, $ttl, $preFetch); } /** * @param mixed $sql * @param array|null $array * @return mixed * @throws RouteNotMatchedException */ public function getScalar(mixed $sql, ?array $array = null): mixed { $dbDriver = $this->matchRoute($sql); return $dbDriver->getScalar($sql, $array); } /** * @param string $tablename * @throws NotImplementedException */ public function getAllFields(string $tablename): array { throw new NotImplementedException('Feature not available'); } /** * @param mixed $sql * @param array|null $array * @return bool * @throws RouteNotMatchedException */ public function execute(mixed $sql, ?array $array = null): bool { $dbDriver = $this->matchRoute($sql); return $dbDriver->execute($sql, $array); } /** * @param IsolationLevelEnum|null $isolationLevel * @throws NotImplementedException */ public function beginTransaction(?IsolationLevelEnum $isolationLevel = null, bool $allowJoin = false) { throw new NotImplementedException('Feature not available'); } /** * @throws NotImplementedException */ public function commitTransaction(): void { throw new NotImplementedException('Feature not available'); } /** * @throws NotImplementedException */ public function rollbackTransaction(): void { throw new NotImplementedException('Feature not available'); } /** * @return mixed * @throws NotImplementedException */ public function getDbConnection(): mixed { throw new NotImplementedException('Feature not available'); } /** * @param string $name * @param mixed $value * @throws NotImplementedException */ public function setAttribute(string $name, mixed $value): void { throw new NotImplementedException('Feature not available'); } /** * @param string $name * @throws NotImplementedException */ public function getAttribute(string $name): mixed { throw new NotImplementedException('Feature not available'); } /** * @param string $sql * @param array|null $array * @return mixed * @throws RouteNotMatchedException */ public function executeAndGetId(string $sql, ?array $array = null): mixed { $dbDriver = $this->matchRoute($sql); return $dbDriver->executeAndGetId($sql, $array); } /** * @return DbFunctionsInterface * @throws NotImplementedException */ public function getDbHelper(): DbFunctionsInterface { throw new NotImplementedException('Feature not available'); } /** * @return Uri * @throws NotImplementedException */ public function getUri(): Uri { throw new NotImplementedException('Feature not available'); } /** * @throws NotImplementedException */ public function isSupportMultiRowset(): bool { throw new NotImplementedException('Feature not available'); } /** * @param bool $multipleRowSet * @throws NotImplementedException */ public function setSupportMultiRowset(bool $multipleRowSet): void { throw new NotImplementedException('Feature not available'); } public function getMaxStmtCache(): int { throw new NotImplementedException('Feature not available'); } public function setMaxStmtCache(int $maxStmtCache): void { throw new NotImplementedException('Feature not available'); } public function getCountStmtCache(): int { throw new NotImplementedException('Feature not available'); } public function reconnect(bool $force = false): bool { throw new NotImplementedException('Feature not available'); } public function disconnect(): void { throw new NotImplementedException('Feature not available'); } public function isConnected(bool $softCheck = false, bool $throwError = false): bool { throw new NotImplementedException('Feature not available'); } public function enableLogger(LoggerInterface $logger): void { throw new NotImplementedException('Feature not available'); } public function log(string $message, array $context = []): void { throw new NotImplementedException('Feature not available'); } public function hasActiveTransaction(): bool { throw new NotImplementedException('Feature not available'); } public function requiresTransaction(): void { throw new NotImplementedException('Feature not available'); } public function activeIsolationLevel(): ?IsolationLevelEnum { throw new NotImplementedException('Feature not available'); } public function remainingCommits(): int { throw new NotImplementedException('Feature not available'); } }__halt_compiler();----SIGNATURE:----g9DdUaQeeQF6QWVZA0Ov9fPhERImT0KVj78AOE4K/7wsI4F532Y8BC2/KBpnxIjOE8Wb/jTGXOfYah/WzjnWmgAIGscxTDGHw80+W7OvVfFtuzDSya+qhZPt5XLaLmsYwtKa26dj+qqlLEElWU2i/uDi/Ws8W96Pggv0BHfgVGj+YMOCFEiCye/W2JRfLiY0PxhtbKcNVy0pp1CA9x2RK61lH2VbfZ8ew7UY8Vx47ProoyFeko+Nd/p+SX6VmDxhlNB+8OYBY2PRmz1s8Bay3sETmwmvyFfNnrZN/PWOXL6Y+IFvfD/IKTmaLa92heLcIJHBfNy41Se7GioiQPc54ILJ+1SgHTTEKQpaadfZh5Gy42mM7Z4B/WyItmljArHyu515uYwa5Vklk3NgSoDQVUiiBIEZwinDTKS487BSCUexVuFf2EiYZ9skhuBnNX8cg6fQGRdQOqK2NDHWc7RLSsc4tYvp84koHIQD65dYSYej/ov2QzSgaFK5ziCYZDOkb2iIVd5nKMYUiUNBd0fiYrODXv2wstxcN1HVuFuS6Yyht6d1mjb8Tp0hV3rfbYKIIFQTUj8aVQITl0O2akaxoScH6EfQ/TFO8aJYx0opWsV2Zb3Zg1/G5D3Y39Z531UbvKUS1hFuppubXmzDOgjMip/7nDEw22t3A7kUz87Wz+8=----ATTACHMENT:----NzgwMjk5NDUyNDI3OTAyMyAzMjUxMTU2NzIxNDU1MTMxIDM5MTM1MDIyNTg0NDk1NzM=