本文整理汇总了PHP中DatabaseUpdater::output方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseUpdater::output方法的具体用法?PHP DatabaseUpdater::output怎么用?PHP DatabaseUpdater::output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseUpdater
的用法示例。
在下文中一共展示了DatabaseUpdater::output方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_clean_math_table
/**
* @author Władysław Bodzek <wladek@wikia-inc.com>
* @modify Piotr Molski <moli@wikia-inc.com>
*/
public static function do_clean_math_table(DatabaseUpdater $updater)
{
$db = $updater->getDB();
$table = 'math';
$primaryKey = 'math_inputhash';
$fields = array('math_inputhash', 'math_outputhash', 'math_html', 'math_mathml');
$updater->output("Checking {$table} table and removing rows with different encoding than utf8...\n");
if ($db->tableExists($table)) {
$updater->output("...scanning table...");
// Read the whole table
$allFields = array_unique(array_merge($fields, array($primaryKey)));
$res = $db->select(" `{$table}`", $allFields, '', __METHOD__);
// scan for all rows containing text which is not in utf8 encoding
$wrong = array();
while ($row = $db->fetchRow($res)) {
foreach ($fields as $field) {
if (!self::is_valid_utf8_text($row[$field])) {
$wrong[] = $row[$primaryKey];
break;
}
}
}
$db->freeResult($res);
$count = count($wrong);
$updater->output("ok (found " . count($wrong) . " rows)\n");
// and finally remove all the malformed rows
if ($count > 0) {
$updater->output("...removing malformed rows...");
$pos = 0;
$chunkSize = 500;
while ($pos < $count) {
$removing = array_slice($wrong, $pos, $chunkSize);
$res = $db->delete($table, array($primaryKey => $removing), __METHOD__);
$pos += $chunkSize;
}
$updater->output("ok\n");
}
}
}