Related

Denic

File comparison tools

Apache access log file

Quad Boot

Linux commands

Featured

Enea (Ersan Elmasa)

Name

Baby

I AM GETTING MARRIED

Fuck biology

Things I would like to do before death

Newest

Award

Graduation

Internet privacy

SSI to php

IE 6 on Ubuntu 9.10

Random

Gradacac (born in) II

IE 6 on Ubuntu 9.10

Hattrick - IV.17 - Mladost 2 : 5 Ersan

Honeymoon in Dubai IV

Audacity – Djevada Christ

MySQL database replace

Thursday, December 30, 2010 06:28:26

Below script replaces some text, in column, with another in specified database on mysql server.
I am posting this as copy/paste reference sometimes in future...

<?php
mysql_connect('host','user','pass');
mysql_select_db('database');
$result_table = mysql_query('SHOW TABLES');
while ($row = mysql_fetch_array($result_table))
{
    foreach ($row as $key => $table)
    {
        $result_column = mysql_query('SHOW COLUMNS FROM $table');
        while ($row_column = mysql_fetch_array($result_column))
        {
            mysql_query(UPDATE $table SET $column = REPLACE($row_column['Field'], 'replace me', 'with me'));
        }
    }
}
?>



Comments

Betmen     Thursday, March 31, 2011 17:46:15
http://historijagradacac.blogger.ba/
.............................................................

Your email address:


*Your name:


Your website:


*Please type number shown on the right side of the text box:
verification image, type it in the box

*Comment: