Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Need Help Stringing Some Php Commands Together

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Need Help Stringing Some Php Commands Together

Postby DirectoryConsultancy » Wed Oct 03, 2012 2:20 am

Hi, please could someone help me

I need to string several about 30 in total commands together in total

An example of the commands are:[code][
UPDATE `property` SET `description` = replace(description, "é", "e")
UPDATE `property` SET `description` = replace(description, "á", "a")
UPDATE `property` SET `description` = replace(description, "St.", "St ")
UPDATE `property` SET `description` = replace(description, "Ü", "u")
UPDATE `property` SET `description` = replace(description, "È", "e")
UPDATE `property` SET `description` = replace(description, "ü", "u")
UPDATE `property` SET `description` = replace(description, "ü", "u")
UPDATE `property` SET `description` = replace(description, "ß", "ss")
UPDATE `property` SET `description` = replace(description, "Ö", "o")/code]

Now I have to run each one separately and manually

I would like to be able to join them all together and run them all in one file and then I could set up a cron job for one file

Last time I tried I unwittingly deleted all the descriptions, nightmare!

Please can someone help me?

Thanks
DirectoryConsultancy
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Oct 03, 2012 1:54 am

Re: Need Help Stringing Some Php Commands Together

Postby seandisanti » Wed Oct 03, 2012 9:04 am

it's not as readable, but you can nest your replace statements so that the return of one is used as the primary string for the next. luckily since whitespace doesn't matter your code can kind of reflect the nesting so it's easier to keep track of. here's an example doing 3 replacements in one line.

Code: Select all
UPDATE 'property'  SET 'description' = replace(
                                 replace(
                                    replace('description',"é", "e")
                                 ,"á", "a"),
                              "St.", "St ");



***edit***
fixed typo
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 773
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.