本文整理汇总了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;
}
}
}
示例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;
}