} function infoCountEmpty($table, $field, $nonEmpty = false) { $sql = "SELECT COUNT(*) FROM {$table}"; if ($nonEmpty) { $sql .= " WHERE {$field} IS NOT NULL OR {$field} != ''"; $negation = ' non'; } else { $sql .= " WHERE {$field} IS NULL OR {$field} = ''"; $negation = ''; } $comment = "Nombre de champs '{$field}'{$negation} vides dans la table '{$table}'."; info($sql, $comment, true); } /* Parses options. */ $opts = Console_GetOpt::getopt($argv, 'v'); $opt_verbose = false; if (PEAR::isError($opts)) { echo $opts->getMessage(); } else { $opts = $opts[0]; foreach ($opts as $opt) { switch ($opt[0]) { case 'v': $opt_verbose = true; break; } } } /* Checks rewriting on deleted aliases. */ check("SELECT s1.email, r.redirect, r.rewrite AS broken\n FROM email_redirect_account AS r\n INNER JOIN email_source_account AS s1 ON (r.uid = s1.uid AND s1.type = 'forlife')\n LEFT JOIN email_source_account AS s2 ON (r.uid = s2.uid AND r.rewrite LIKE CONCAT(s2.email, '@%'))\n WHERE r.rewrite != '' AND s2.uid IS NULL", "Personnes qui ont des rewrite sur un alias perdu.");