本文整理汇总了PHP中c::escRegex方法的典型用法代码示例。如果您正苦于以下问题:PHP c::escRegex方法的具体用法?PHP c::escRegex怎么用?PHP c::escRegex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c
的用法示例。
在下文中一共展示了c::escRegex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createTables
/**
* Create DB tables.
*
* @since 160524 DB utils.
*/
public function createTables()
{
$table_prefix = $this->prefix();
// For the app.
$tables_dir = $this->App->Config->©fs_paths['§mysql']['§tables_dir'];
$indexes_dir = $this->App->Config->©fs_paths['§mysql']['§indexes_dir'];
$triggers_dir = $this->App->Config->©fs_paths['§mysql']['§triggers_dir'];
if (!$tables_dir || !is_dir($tables_dir)) {
return;
// Not possible; no tables.
}
foreach ($this->c::dirRegexRecursiveIterator($tables_dir, '/\\.sql$/ui') as $_Resource) {
if (!$_Resource->isFile()) {
// Not a file?
continue;
// Bypass; files only.
}
$_sql_file = $_Resource->getPathname();
$_sql_file_table = basename($_sql_file, '.sql');
$_sql_file_table = str_replace('-', '_', $_sql_file_table);
$_sql_file_table = $table_prefix . $_sql_file_table;
$_sql = $this->c::mbTrim(file_get_contents($_sql_file));
$_sql = str_replace('%%table%%', $_sql_file_table, $_sql);
$_sql = $this->charsetCompat($this->engineCompat($this->ifNotExists($_sql)));
$_sql_check = $this->wp->prepare('SHOW TABLES LIKE %s', $_sql_file_table);
if ($this->wp->get_var($_sql_check) === $_sql_file_table) {
continue;
// Table exists already. Nothing to do.
}
if (!$_sql || $this->wp->query($_sql) === false) {
// Table creation failure?
throw $this->c::issue(sprintf('DB table creation failure. Table: `%1$s`. SQL: `%2$s`.', $_sql_file_table, $_sql));
}
foreach ([$indexes_dir, $triggers_dir] as $_tables_after_dir) {
if ($_tables_after_dir && is_dir($_tables_after_dir)) {
// ↓ Looking for additional files for this specific table.
$_tables_after_regex = '/\\/' . c::escRegex(basename($_sql_file)) . '$/ui';
foreach ($this->c::dirRegexRecursiveIterator($_tables_after_dir, $_tables_after_regex) as $__Resource) {
if (!$__Resource->isFile()) {
// Not a file?
continue;
// Bypass; files only.
}
$__sql_file = $__Resource->getPathname();
$__sql = $this->c::mbTrim(file_get_contents($__sql_file));
$__sql = str_replace('%%table%%', $_sql_file_table, $__sql);
if ($this->wp->query($__sql) === false) {
// Index creation failure?
throw $this->c::issue(sprintf('DB query failure. Table: `%1$s`. SQL: `%2$s`.', $_sql_file_table, $__sql));
}
}
// unset($__Resource, $__sql_file, $__sql);
}
}
// unset($_tables_after_dir, $_tables_after_regex);
}
// unset($_Resource, $_sql_file, $_sql_file_table, $_sql_check, $_sql);
}