|
Posted by Chung Leong on 10/28/06 01:43
Rik wrote:
>
> Well, it would be simpler for us if you could describe what it is exactly
> what you're trying to do, instead of letting us decypher it.
>
> 1. You can use a WHERE REGEXP to have a small result to check from the
> database.
> 2. In the case, I really advise preg_replace() to change the img src
> instead of the exploding, looping strpos, str_replace etc. This can be a
> one-liner.
> 3. MySQL has a handy REPLACE INTO, as long as you have a correct key, it
> would mean that no checking on already existing rows is required.
> --
> Rik Wasmus
Combining all the insert/replace operation into one statement would
help as well. Instead of doing a query immediate, store the links in
different arrays like this:
$images[$url] = true;
That collapses duplicate links in the page being parsed. Then it's just
a matter of looping through the arrays to build sql statements that
would create the records in one fell swoop.
Navigation:
[Reply to this message]
|