mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-19 04:58:41 +00:00
This commit is contained in:
parent
a5ee11721f
commit
a25870500e
|
|
@ -117,7 +117,13 @@ class MysqlGrammar extends Grammar
|
|||
->from('information_schema.tables')
|
||||
->where('table_schema', '=', $query->getConnection()->getDatabase());
|
||||
|
||||
return \rtrim($builder->toSql(), ';');
|
||||
$sql = $builder->toSql();
|
||||
|
||||
foreach ($builder->binds as $bind) {
|
||||
$query->bind($bind);
|
||||
}
|
||||
|
||||
return \rtrim($sql, ';');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -138,7 +144,13 @@ class MysqlGrammar extends Grammar
|
|||
->where('table_schema', '=', $query->getConnection()->getDatabase())
|
||||
->andWhere('table_name', '=', $table);
|
||||
|
||||
return \rtrim($builder->toSql(), ';');
|
||||
$sql = $builder->toSql();
|
||||
|
||||
foreach ($builder->binds as $bind) {
|
||||
$query->bind($bind);
|
||||
}
|
||||
|
||||
return \rtrim($sql, ';');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -44,7 +44,13 @@ class PostgresGrammar extends Grammar
|
|||
->from('information_schema.tables')
|
||||
->where('table_schema', '=', $query->getConnection()->getDatabase());
|
||||
|
||||
return \rtrim($builder->toSql(), ';');
|
||||
$sql = $builder->toSql();
|
||||
|
||||
foreach ($builder->binds as $bind) {
|
||||
$query->bind($bind);
|
||||
}
|
||||
|
||||
return \rtrim($sql, ';');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -65,7 +71,13 @@ class PostgresGrammar extends Grammar
|
|||
->where('table_schema', '=', $query->getConnection()->getDatabase())
|
||||
->andWhere('table_name', '=', $table);
|
||||
|
||||
return \rtrim($builder->toSql(), ';');
|
||||
$sql = $builder->toSql();
|
||||
|
||||
foreach ($builder->binds as $bind) {
|
||||
$query->bind($bind);
|
||||
}
|
||||
|
||||
return \rtrim($sql, ';');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -54,7 +54,13 @@ class SQLiteGrammar extends Grammar
|
|||
->from('sqlite_master')
|
||||
->where('type', '=', 'table');
|
||||
|
||||
return \rtrim($builder->toSql(), ';');
|
||||
$sql = $builder->toSql();
|
||||
|
||||
foreach ($builder->binds as $bind) {
|
||||
$query->bind($bind);
|
||||
}
|
||||
|
||||
return \rtrim($sql, ';');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -67,7 +73,13 @@ class SQLiteGrammar extends Grammar
|
|||
->from('pragma_table_info(\'' . $table . '\')')
|
||||
->where('pragma_table_info(\'' . $table . '\')', '=', $table);
|
||||
|
||||
return \rtrim($builder->toSql(), ';');
|
||||
$sql = $builder->toSql();
|
||||
|
||||
foreach ($builder->binds as $bind) {
|
||||
$query->bind($bind);
|
||||
}
|
||||
|
||||
return \rtrim($sql, ';');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -82,7 +82,13 @@ class SqlServerGrammar extends Grammar
|
|||
->where('table_schema', '=', $query->getConnection()->getDatabase())
|
||||
->andWhere('table_name', '=', $table);
|
||||
|
||||
return \rtrim($builder->toSql(), ';');
|
||||
$sql = $builder->toSql();
|
||||
|
||||
foreach ($builder->binds as $bind) {
|
||||
$query->bind($bind);
|
||||
}
|
||||
|
||||
return \rtrim($sql, ';');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -53,7 +53,11 @@ abstract class StatusAbstract
|
|||
* @var array<string, array>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static array $routes = [];
|
||||
public static array $routes = [];
|
||||
|
||||
public static array $hooks = [];
|
||||
|
||||
private static array $cache = [];
|
||||
|
||||
/**
|
||||
* Deactivate module.
|
||||
|
|
@ -117,17 +121,17 @@ abstract class StatusAbstract
|
|||
throw new PermissionException($destRoutePath); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
if (!isset(self::$routes[$destRoutePath])) {
|
||||
if (!isset(self::$cache[$destRoutePath])) {
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
self::$routes[$destRoutePath] = include $destRoutePath;
|
||||
self::$cache[$destRoutePath] = include $destRoutePath;
|
||||
}
|
||||
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
$moduleRoutes = include $srcRoutePath;
|
||||
$moduleCache = include $srcRoutePath;
|
||||
|
||||
self::$routes[$destRoutePath] = \array_merge_recursive(self::$routes[$destRoutePath], $moduleRoutes);
|
||||
self::$cache[$destRoutePath] = \array_merge_recursive(self::$cache[$destRoutePath], $moduleCache);
|
||||
|
||||
\file_put_contents($destRoutePath, '<?php return ' . ArrayParser::serializeArray(self::$routes[$destRoutePath]) . ';', \LOCK_EX);
|
||||
\file_put_contents($destRoutePath, '<?php return ' . ArrayParser::serializeArray(self::$cache[$destRoutePath]) . ';', \LOCK_EX);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -158,7 +162,11 @@ abstract class StatusAbstract
|
|||
*/
|
||||
public static function activateRoutesHooks(ModuleInfo $info, string $type, ?ApplicationInfo $appInfo = null) : void
|
||||
{
|
||||
$directories = new Directory(static::PATH . '/' . $type);
|
||||
self::$cache = $type === 'Routes'
|
||||
? self::$routes
|
||||
: self::$hooks;
|
||||
|
||||
$directories = new Directory(static::PATH . '/' . $type);
|
||||
|
||||
/** @var Directory|File $child */
|
||||
foreach ($directories as $child) {
|
||||
|
|
@ -192,6 +200,12 @@ abstract class StatusAbstract
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($type === 'Routes') {
|
||||
self::$routes = self::$cache;
|
||||
} else {
|
||||
self::$hooks = self::$cache;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
|
|||
} elseif ($con instanceof SqlServerConnection) {
|
||||
$sql = 'SELECT * FROM [information_schema].[columns] WHERE [table_schema] = ? AND [table_name] = ?;';
|
||||
} elseif ($con instanceof SQLiteConnection) {
|
||||
$sql = 'SELECT * FROM pragma_table_info(?) WHERE pragma_table_info(\'test\') = ?;';
|
||||
$sql = 'SELECT * FROM pragma_table_info(\'test\') WHERE pragma_table_info(\'test\') = ?;';
|
||||
}
|
||||
|
||||
$sql = \strtr($sql, '[]', $iS . $iE);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user