List:General Discussion« Previous MessageNext Message »
From:Johan De Meersman Date:July 31 2012 8:39am
Subject:Re: how to replace this data in a complex field?
View as plain text  

----- Original Message -----
> From: "Incarus Derp" <icarusderp@stripped>
> 
> 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
Thread
how to replace this data in a complex field?Incarus Derp31 Jul
  • Re: how to replace this data in a complex field?Mihamina Rakotomandimby31 Jul
  • Re: how to replace this data in a complex field?Johan De Meersman31 Jul
    • RE: how to replace this data in a complex field?Rick James1 Aug