[wp-hackers] best route for adding links?

Andy Charrington-Wilden andycharrington at gmail.com
Sat Jan 21 21:21:55 UTC 2012


Surely getting all links in the db once, sticking them in an array and checking if !in_array would be quicker? If a link is to be added (ie it's not in the array) rather than querying the db again for the next one just add it to the array and do the check on the next one in the csv. In fact you could just add the links that are not already present to another array and then run one insert query built from that array. Only two database interactions for the whole thing. That's what I'd do anyway. 

Sent from my iPhone

On 21 Jan 2012, at 19:35, Daniel Dvorkin <elrabino at gmail.com> wrote:

> You can use get_bookmarks (
> http://codex.wordpress.org/Function_Reference/get_bookmarks ) searching for
> that URL. Import only if it returns empty. Not very fast, though.
> 
> 
> 
> 
> ---------------------
> Daniel Dvorkin
> Móvil: +54 (0261) 15-315-2244
> Skype: mzaweb
> http://mzaweb.com
> 
> 
> 
> 
> On Thu, Jan 19, 2012 at 3:15 PM, fris <fris at fris.net> wrote:
> 
>> What would be the best way to avoid adding duplicate links.
>> 
>> Im creating a csv link importer, and using wp_insert_link() , but currently
>> its adding the link even if one exists with the same url.
>> 
>> 
>> 
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>> 
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list