本文整理汇总了PHP中utf8::strip_non_ascii方法的典型用法代码示例。如果您正苦于以下问题:PHP utf8::strip_non_ascii方法的具体用法?PHP utf8::strip_non_ascii怎么用?PHP utf8::strip_non_ascii使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utf8
的用法示例。
在下文中一共展示了utf8::strip_non_ascii方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute_sql_scripts
/**
* execute all sql srips from the upgrade folder
*
* @param string $baseDir directory to the module folder updgrades are in.
* @param string $upgrade_folder folder version name
*/
public function execute_sql_scripts($baseDir, $upgrade_folder, $appName, &$last_run_script)
{
$file_name = array();
$full_upgrade_folder = $baseDir . "db/" . $upgrade_folder;
// get last executed sql file name. If not in the parameter (which loads from the db via the
// system model), then it could be from an old version of Indicia pre 0.8 so has the last
// run script saved as a file in the db scripts folder. Or we could just be starting a new folder.
if (empty($last_run_script)) {
$last_run_script = $this->get_last_executed_sql_file_name($full_upgrade_folder, $appName);
}
$original_last_run_script = $last_run_script;
if (($handle = @opendir($full_upgrade_folder)) != FALSE) {
while (($file = readdir($handle)) != false) {
if (!preg_match("/^20.*\\.sql\$/", $file)) {
continue;
}
$file_name[] = $file;
}
@closedir($handle);
} else {
throw new Exception("Cant open dir " . $full_upgrade_folder);
}
sort($file_name);
try {
foreach ($file_name as $name) {
if (strcmp($name, $last_run_script) > 0 || empty($last_run_script)) {
if (false === ($_db_file = file_get_contents($full_upgrade_folder . '/' . $name))) {
throw new Exception("Can't open file " . $full_upgrade_folder . '/' . $name);
}
kohana::log('debug', "Upgrading file {$name}");
// @todo Look into why utf8 files do not run without conversion to ascii.
if (!utf8::is_ascii($_db_file)) {
$_db_file = utf8::strip_non_ascii($_db_file);
}
if (substr($_db_file, 0, 18) === '-- #postgres user#') {
$this->scriptsForPgUser .= $_db_file . "\n\n";
} elseif (substr($_db_file, 0, 16) === '-- #slow script#' && $this->couldBeSlow) {
$this->slowScripts .= $_db_file . "\n\n";
} else {
$result = $this->db->query($_db_file);
}
$last_run_script = $name;
}
}
} catch (Exception $e) {
kohana::log('error', "Error in file: " . $full_upgrade_folder . '/' . $name);
kohana::log('error', $e->getMessage());
throw $e;
}
$this->update_last_executed_sql_file($full_upgrade_folder, $appName, $original_last_run_script, $last_run_script);
return true;
}