/[drupal]/contributions/modules/subscriptions/subscriptions_taxonomy.install
ViewVC logotype

Contents of /contributions/modules/subscriptions/subscriptions_taxonomy.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Mon Jul 20 22:37:57 2009 UTC (4 months ago) by salvis
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-RC1, DRUPAL-6--1-0, DRUPAL-6--1-1, DRUPAL-6--1-0-BETA6, HEAD
Changes since 1.2: +7 -3 lines
File MIME type: text/x-php
Fix the fix: MySQL doesn't like CAST(... AS VARCHAR).
1 <?php
2 // $Id: subscriptions_taxonomy.install,v 1.2 2009/07/20 21:55:53 salvis Exp $
3
4 /**
5 * @file
6 * Subscriptions Taxonomy module installation.
7 */
8
9 /**
10 * Implementation of hook_install().
11 */
12 function subscriptions_taxonomy_install() {
13 }
14
15 /**
16 * Database update function 2 (replaces update function 1!).
17 *
18 * Remove taxonomy subscriptions left over from deleted terms.
19 */
20 function subscriptions_taxonomy_update_2() {
21 $result = db_query("SELECT s.value AS tid FROM {subscriptions_queue} s LEFT JOIN {term_data} t ON s.value = ". ($GLOBALS['db_type'] == 'pgsql' ? 'CAST(' : '')
22 ."t.tid". ($GLOBALS['db_type'] == 'pgsql' ? ' AS VARCHAR)' : '')
23 ." WHERE s.module = 'node' AND s.field = 'tid' AND t.tid IS NULL");
24 while ($orphan = db_fetch_array($result)) {
25 $orphans[] = $orphan['tid'];
26 }
27 if (isset($orphans)) {
28 db_query("DELETE FROM {subscriptions_queue} WHERE module = 'node' AND field = 'tid' AND value IN (". db_placeholders($orphans, 'varchar') .")", $orphans);
29 $orphans = NULL;
30 }
31 $result = db_query("SELECT s.value AS tid FROM {subscriptions} s LEFT JOIN {term_data} t ON s.value = ". ($GLOBALS['db_type'] == 'pgsql' ? 'CAST(' : '')
32 ."t.tid". ($GLOBALS['db_type'] == 'pgsql' ? ' AS VARCHAR)' : '')
33 ." WHERE s.module = 'node' AND s.field = 'tid' AND t.tid IS NULL");
34 while ($orphan = db_fetch_array($result)) {
35 $orphans[] = $orphan['tid'];
36 }
37 if (isset($orphans)) {
38 db_query("DELETE FROM {subscriptions} WHERE module = 'node' AND field = 'tid' AND value IN (". db_placeholders($orphans, 'varchar') .")", $orphans);
39 }
40 return array();
41 }
42
43 /**
44 * Implementation of hook_uninstall().
45 */
46 function subscriptions_taxonomy_uninstall() {
47 }

  ViewVC Help
Powered by ViewVC 1.1.2