From daf845dbe67a909e2bc9e039d3c2ccc560345b4d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 28 May 2009 16:36:07 -0400 Subject: [PATCH] take an argument for fixup_utf8 --- scripts/fixup_utf8.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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); -- 2.39.5