With a moderate amount of rows such as you have, my recommendation
would be to run a task/script to loop through and change the rows one
by one and resave them... I would do the replacement in PHP, rather
than SQL, and do it once, rather than filter the value each time it is
requested.
eg:
$db->query("select * from table");
$records= $db->getRecords();
foreach($records as $record) {
$text = $record->text;
$text =
preg_replace("/\"mailto\:em...@address\.com\?subject=[a-za-z\s0-9]+\"/",
'"form_url.php"', $text);
$record->text = $text;
$record->save();
}
If you were using raw sql, it would be UPDATE blah etc... instead of
$record->save(). The idea being to just run the update once, and clean
up each row one by one. Having an ORM naturally makes this process a
lot more straightforward.
Grüße,
Mark Rickerby
http://maetl.net/
-------------------------------------------------------------------------------
Cell. +642102785644 | Email. [email protected]
PO Box 4452, Shortland Street, Auckland 1140, NZ
-------------------------------------------------------------------------------
On Fri, Jun 19, 2009 at 1:15 PM, David
Turton<[email protected]> wrote:
> Hi All,
>
> I’m familiar with regular expressions, and I’m familiar with replace sql
> queries, but I can’t get them working together. Google and mysql.com haven’t
> been much help.
>
>
>
> Or other suggestions for doing this are welcome??
>
>
>
> Need to replace
>
>
>
> <a href=”mailto:[email protected]?subject=a Subject String”><img
> src=”img.gif” /></a>
>
>
>
> With
>
>
>
> <a href=”form_url.php”><img src=”img.gif” /></a>
>
>
>
> The variable is the “A Subject String”, all else is common across all
> records. They are all strings, alphanumeric only e.g. [A-Za-z0-9 ] selects
> all records.
>
> There are 102 records.
>
>
>
> Thanks for any help.
>
> Cheers
>
> Dave T
>
>
>
> ________________________________
> Warning: This email contains information which is CONFIDENTIAL and may also
> be LEGALLY PRIVILEGED. If you are not the intended recipient you must not
> peruse, use, disseminate, distribute or copy this email or attachments. If
> you have received this in error, please notify us immediately by return
> email and delete this email.
> Thank you.
> ________________________________
> This e-mail message has been scanned for Viruses and Content and cleared by
> MailMarshal
> ________________________________
> >
>
--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---