Index: modules/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy.module,v retrieving revision 1.217 diff -u -F^f -r1.217 taxonomy.module --- modules/taxonomy.module 25 Jul 2005 04:55:37 -0000 1.217 +++ modules/taxonomy.module 8 Aug 2005 05:38:33 -0000 @@ -142,7 +142,7 @@ function taxonomy_save_vocabulary($edit) $data = array('name' => $edit['name'], 'description' => $edit['description'], 'help' => $edit['help'], 'multiple' => $edit['multiple'], 'required' => $edit['required'], 'hierarchy' => $edit['hierarchy'], 'relations' => $edit['relations'], 'tags' => $edit['tags'], 'weight' => $edit['weight'], 'module' => isset($edit['module']) ? $edit['module'] : 'taxonomy'); if ($edit['vid'] && $edit['name']) { - db_query('UPDATE {vocabulary} SET '. _taxonomy_prepare_update($data) .' WHERE vid = %d', $edit['vid']); + db_query('UPDATE {vocabulary} SET %a WHERE vid = %d', $data, $edit['vid']); db_query("DELETE FROM {vocabulary_node_types} WHERE vid = %d", $edit['vid']); foreach ($edit['nodes'] as $type) { db_query("INSERT INTO {vocabulary_node_types} (vid, type) VALUES (%d, '%s')", $edit['vid'], $type); @@ -155,7 +155,7 @@ function taxonomy_save_vocabulary($edit) } else { $data['vid'] = $edit['vid'] = db_next_id('{vocabulary}_vid'); - db_query('INSERT INTO {vocabulary} '. _taxonomy_prepare_insert($data, 1) .' VALUES '. _taxonomy_prepare_insert($data, 2)); + db_query('INSERT INTO {vocabulary} %a', $data); foreach ($edit['nodes'] as $type) { db_query("INSERT INTO {vocabulary_node_types} (vid, type) VALUES (%d, '%s')", $edit['vid'], $type); } @@ -255,7 +255,7 @@ function taxonomy_save_term($edit) { if ($edit['tid'] && $edit['name']) { $data = array('name' => $edit['name'], 'description' => $edit['description'], 'weight' => $edit['weight']); - db_query('UPDATE {term_data} SET '. _taxonomy_prepare_update($data) .' WHERE tid = %d', $edit['tid']); + db_query('UPDATE {term_data} SET %a WHERE tid = %d', $data, $edit['tid']); module_invoke_all('taxonomy', 'update', 'term', $edit); $status = SAVED_UPDATED; } @@ -265,7 +265,7 @@ function taxonomy_save_term($edit) { else { $edit['tid'] = db_next_id('{term_data}_tid'); $data = array('tid' => $edit['tid'], 'name' => $edit['name'], 'description' => $edit['description'], 'vid' => $edit['vid'], 'weight' => $edit['weight']); - db_query('INSERT INTO {term_data} '. _taxonomy_prepare_insert($data, 1) .' VALUES '. _taxonomy_prepare_insert($data, 2)); + db_query('INSERT INTO {term_data} %a', $data); module_invoke_all('taxonomy', 'insert', 'term', $edit); $status = SAVED_NEW; } @@ -903,33 +903,6 @@ function _taxonomy_depth($depth, $graphi return $result; } -function _taxonomy_prepare_update($data) { - foreach ($data as $key => $value) { - $q[] = "$key = '". str_replace('%', '%%', db_escape_string($value)) ."'"; - } - $result = implode(', ', $q); - return $result; -} - -function _taxonomy_prepare_insert($data, $stage) { - if ($stage == 1) { - $result = implode(', ', array_keys($data)); - } - else { - foreach (array_values($data) as $value) { - //Escape strings, but not integers - if (is_int($value)) { - $q[] = $value; - } - else { - $q[] = "'". str_replace('%', '%%', db_escape_string($value)) ."'"; - } - } - $result = implode(', ', $q); - } - return "($result)"; -} - /** * Finds all nodes that match selected taxonomy conditions. *