当前位置: 首页>>代码示例>>PHP>>正文


PHP utf8::strip_non_ascii方法代码示例

本文整理汇总了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;
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:58,代码来源:upgrade.php


注:本文中的utf8::strip_non_ascii方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。