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


PHP JDatabaseDriver::convertUtf8mb4QueryToUtf8方法代码示例

本文整理汇总了PHP中JDatabaseDriver::convertUtf8mb4QueryToUtf8方法的典型用法代码示例。如果您正苦于以下问题:PHP JDatabaseDriver::convertUtf8mb4QueryToUtf8方法的具体用法?PHP JDatabaseDriver::convertUtf8mb4QueryToUtf8怎么用?PHP JDatabaseDriver::convertUtf8mb4QueryToUtf8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JDatabaseDriver的用法示例。


在下文中一共展示了JDatabaseDriver::convertUtf8mb4QueryToUtf8方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fix

 /**
  * Runs the update query to apply the change to the database
  *
  * @return  void
  *
  * @since   2.5
  */
 public function fix()
 {
     if ($this->checkStatus === -2) {
         // At this point we have a failed query
         $query = $this->db->convertUtf8mb4QueryToUtf8($this->updateQuery);
         $this->db->setQuery($query);
         if ($this->db->execute()) {
             if ($this->check()) {
                 $this->checkStatus = 1;
                 $this->rerunStatus = 1;
             } else {
                 $this->rerunStatus = -2;
             }
         } else {
             $this->rerunStatus = -2;
         }
     }
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:25,代码来源:changeitem.php

示例2: populateDatabase

 /**
  * Method to import a database schema from a file.
  *
  * @param   JDatabaseDriver  $db      JDatabase object.
  * @param   string           $schema  Path to the schema file.
  *
  * @return  boolean  True on success.
  *
  * @since   3.1
  */
 public function populateDatabase($db, $schema)
 {
     // Get the application
     /* @var InstallationApplicationWeb $app */
     $app = JFactory::getApplication();
     $return = true;
     // Get the contents of the schema file.
     if (!($buffer = file_get_contents($schema))) {
         $app->enqueueMessage($db->getErrorMsg(), 'notice');
         return false;
     }
     // Get an array of queries from the schema and process them.
     $queries = $this->_splitQueries($buffer);
     foreach ($queries as $query) {
         // Trim any whitespace.
         $query = trim($query);
         // If the query isn't empty and is not a MySQL or PostgreSQL comment, execute it.
         if (!empty($query) && $query[0] != '#' && $query[0] != '-') {
             /**
              * If we don't have UTF-8 Multibyte support we'll have to convert queries to plain UTF-8
              *
              * Note: the JDatabaseDriver::convertUtf8mb4QueryToUtf8 performs the conversion ONLY when
              * necessary, so there's no need to check the conditions in JInstaller.
              */
             $query = $db->convertUtf8mb4QueryToUtf8($query);
             /**
              * This is a query which was supposed to convert tables to utf8mb4 charset but the server doesn't
              * support utf8mb4. Therefore we don't have to run it, it has no effect and it's a mere waste of time.
              */
             if (!$db->hasUTF8mb4Support() && stristr($query, 'CONVERT TO CHARACTER SET utf8 ')) {
                 continue;
             }
             // Execute the query.
             $db->setQuery($query);
             try {
                 $db->execute();
             } catch (RuntimeException $e) {
                 $app->enqueueMessage($e->getMessage(), 'notice');
                 $return = false;
             }
         }
     }
     return $return;
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:54,代码来源:database.php


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