From: Evan Prodromou Date: Thu, 28 May 2009 20:36:07 +0000 (-0400) Subject: take an argument for fixup_utf8 X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=daf845dbe67a909e2bc9e039d3c2ccc560345b4d;p=quix0rs-gnu-social.git take an argument for fixup_utf8 --- diff --git a/scripts/fixup_utf8.php b/scripts/fixup_utf8.php index 0763c72c91..e5021ff343 100644 --- a/scripts/fixup_utf8.php +++ b/scripts/fixup_utf8.php @@ -35,7 +35,7 @@ define('LACONICA', true); require_once(INSTALLDIR . '/lib/common.php'); require_once('DB.php'); -function main() { +function fixup_utf8($id) { $dbl = doConnect('latin1'); @@ -58,8 +58,16 @@ function main() { return; } - $rn = $dbl->query('SELECT id, content, rendered FROM notice ' . - 'WHERE LENGTH(content) != CHAR_LENGTH(content)'); + $sql = 'SELECT id, content, rendered FROM notice ' . + 'WHERE LENGTH(content) != CHAR_LENGTH(content)'; + + if (!empty($id)) { + $sql .= ' AND id < ' . $id; + } + + $sql .= ' ORDER BY id DESC'; + + $rn = $dbl->query($sql); if (PEAR::isError($rn)) { echo "ERROR: " . $rn->getMessage() . "\n"; @@ -128,4 +136,6 @@ function doConnect($charset) return $db; } -main(); +$id = ($argc > 1) ? $argv[1] : null; + +fixup_utf8($id);