+ function fixupProfiles()
+ {
+ // Do a separate DB connection
+
+ $sth = $this->dbu->prepare("UPDATE profile SET ".
+ "fullname = UNHEX(?),".
+ "location = UNHEX(?), ".
+ "bio = UNHEX(?) ".
+ "WHERE id = ?");
+
+ if (PEAR::isError($sth)) {
+ echo "ERROR: " . $sth->getMessage() . "\n";
+ return;
+ }
+
+ $sql = 'SELECT id, fullname, location, bio FROM profile ' .
+ 'WHERE (LENGTH(fullname) != CHAR_LENGTH(fullname) '.
+ 'OR LENGTH(location) != CHAR_LENGTH(location) '.
+ 'OR LENGTH(bio) != CHAR_LENGTH(bio)) '.
+ 'AND modified < "'.$this->max_date.'" '.
+ ' ORDER BY modified DESC';
+
+ $rn = $this->dbl->query($sql);
+
+ if (PEAR::isError($rn)) {
+ echo "ERROR: " . $rn->getMessage() . "\n";
+ return;
+ }
+
+ echo "Number of rows: " . $rn->numRows() . "\n";
+
+ $profile = array();
+
+ while (DB_OK == $rn->fetchInto($profile)) {
+
+ $id = ($profile[0])+0;
+ $fullname = bin2hex($profile[1]);
+ $location = bin2hex($profile[2]);
+ $bio = bin2hex($profile[3]);
+
+ echo "$id...";
+
+ $result =& $this->dbu->execute($sth, array($fullname, $location, $bio, $id));
+
+ if (PEAR::isError($result)) {
+ echo "ERROR: " . $result->getMessage() . "\n";
+ continue;
+ }
+
+ $cnt = $this->dbu->affectedRows();