Esempio n. 1
0
function textFields($className, $name, $value, $yii_t_label)
{
    if (is_array($value)) {
        $result = '';
        foreach ($value as $key => $val) {
            $result .= textFields($className, $name . '[' . $key . ']', $val, $yii_t_label . '.' . $key);
        }
    } else {
        $id = $className . '_value';
        $result = '<label for="' . $id . '">' . Module::t('settings', $yii_t_label) . ':' . Html::textInput($name, $value) . '</label>';
    }
    return $result;
}
Esempio n. 2
0
// CONFIGS
// $tabFieldsTypeText = array("varchar", "tinytext", "text", "mediumtext", "longtext");
$tabFieldsTypeText = null;
$excludedTables = array();
printf("return entries containing pattern '%s'", $regexpPattern);
echo "\nTable   +++     First Field value   +++     field with pattern";
echo "\n________________________________________________________________";
$link = mysql_connect($host, $user, $password) or die("Impossible de se connecter : " . mysql_error());
mysql_select_db($database, $link) or die('Could not select database.');
$strQuery = "Show tables ";
$resSet = mysql_query($strQuery);
$replacementsDone = false;
while ($table = mysql_fetch_array($resSet)) {
    $tableName = $table[0];
    if (!in_array($tableName, $excludedTables)) {
        $aFields = textFields($tableName, $tabFieldsTypeText);
        foreach ($aFields as $field) {
            $strQuery = "select * from " . $tableName . " where " . $field . " regexp '" . $regexpPattern . "' ";
            $resSet2 = mysql_query($strQuery);
            if (is_resource($resSet2)) {
                $found = false;
                while ($entryFound = mysql_fetch_array($resSet2)) {
                    $found = true;
                    printf("\n%s   +++     %s   +++     %s", $tableName, $entryFound[0], $field);
                }
                if (isset($replace) && $found) {
                    $strQuery = "update " . $tableName . " set " . $field . "= replace(" . $field . ",'" . $regexpPattern . "','" . $replace . "');";
                    mysql_query($strQuery);
                    $replacementsDone = true;
                    printf("\n All '%s' occurrences have been replaced by '%s' in field %s", $regexpPattern, $replace, $tableName . "." . $field);
                }