Closed (fixed)
Project:
Taxonomy dupecheck
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
6 Mar 2012 at 14:52 UTC
Updated:
4 Apr 2012 at 19:30 UTC
Instead of this sql query
$sql = "SELECT * FROM {term_data} WHERE vid = %d";
$result = db_query($sql, $vid);
// Look for a term with the same name based on case-sensitivity preferences
$case_sensitive = variable_get('taxonomy_dupecheck_case_sensitive', 0);
while ($found_term = db_fetch_object($result)) {
// Skip the check if the current found term is the same term we're comparing.
// This will happen on updates to an existing term.
if ($tid == $found_term->tid) {
continue;
}
do sg like this:
$sql = "SELECT * FROM {term_data} WHERE vid = %d AND name = '".$term."';
...
There is no need to get the entire vocabulary. Just check if we have a record.
Comments
Comment #1
giorgio79 commentedEven better, use http://api.drupal.org/api/drupal/modules!taxonomy!taxonomy.module/function/taxonomy_get_term_by_name/6
Comment #2
kziv commentedChanging to task, as functionality is not broken.
Comment #3
kziv commentedThis has been optimized in both 6.x and 7.x dev releases. Feel free to play with it and give some feedback. I'll move it to an official release in a couple weeks. Thanks for the suggestion!
Comment #4.0
(not verified) commentedclarify