OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: how to replace this data in a complex field?

From: Johan De Meersman (vegivamptuxera.be)
Date: Tue Jul 31 2012 - 03:39:30 CDT


----- Original Message -----
> From: "Incarus Derp" <icarusderpgmail.com>
>
> I have a complex field named Inventory in a table named Table1 that
> can be different every time and is not guaranteed to contain what I need to
> replace.
>
> [["Thing1","Thing4","thing8","thing1","thing942","ACRE_PRC119_ID_29"],[["thing1700",2],"datthing4","pizza","water","apples,"beans","coke-a-cola","rice","apples","apples","icecream","pizza",["7things",6],"7things","7things","8things","tophats","tophats","762x39mmRU"]]

That looks more like a multidimensional array than a table, to me.

>
> I need to replace ACRE_PRC119_ID_29 with ACRE_PRC119 and I cannot do
> this externally. I have PREG_REPLACE but I'm not sure how I would apply
> this to the database because it only SELECT's as far as I know.

...and preg_replace is a PHP function, not a MySQL one. Are you sure you're on the right list?

In any case, if you're looking to do this in MySQL, this is the function you're probably going to be using:
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace

If you're looking to do those substitutions on an mdarray in PHP, well, wrong list :-) I'll hint you that you're probably going to have to write a recursive function, though, if your mdarray has varying depth.

--
Linux Bier Wanderung 2012, now also available in Belgium!
August, 12 to 19, Diksmuide, Belgium - http://lbw2012.tuxera.be

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql