Fix for db_query reads fail

  1. function uc_imis_pricing_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  2.   // pricing display ingetration point?
  3.  
  4.   // ensure we have a product
  5.   if ($node->model) {
  6.     switch ($op) {
  7.       case 'load':
  8.         global $user;
  9.  
  10.         $data = unserialize($user->data);
  11.         $imis_id = $data['imis_id'];
  12.         //if they're not an iMIS user, use the default pricing as defined on the product
  13.         //if ($imis_id != '') {
  14.           list($meeting, $function) = explode('/', $node->model);
  15.  
  16.           $ws = _build_webservice();
  17.  
  18.           $event = node_load($node->field_event[0]);
  19.  
  20.           $member_type = $ws->get_member_type($imis_id);
  21.  
  22.           $reg_class = $event->reg_class_mappings[$member_type];
  23.  
  24.           if (! $reg_class) {
  25.             // use the default defined on the product
  26.  
  27.             // pick a sensible default, at least for testing
  28.             $reg_class = 'NM';
  29.           }
  30.  
  31.           $node->sell_price = $ws->get_meeting_price($meeting, $function, $reg_class);
  32.          
  33.           //load default class into node
  34.           $query = db_query("SELECT * FROM {uc_imis_pricing WHERE vid = %d AND nid = %d", $node->vid, $node->nid);
  35.          
  36.           dsm($query);
  37.          
  38.           $node->default_class = $query->default_class;
  39.         //}
  40.         break;
  41.      
  42.       case 'view':
  43.         // get rid of the "add to cart" button as we want them to make a registration node
  44.         if(isset($node->content['add_to_cart'])) {
  45.           unset($node->content['add_to_cart']);
  46.         }
  47.         break;
  48.        
  49.       case 'validate':
  50.         // possible discrimination between imis/non imis items?
  51.  
  52.         $ws = _build_webservice();
  53.  
  54.         // verify product exists
  55.         if (! $ws->event_exists($node->model)) {
  56.           form_set_error('model', t('That code does not exist in iMIS.'));
  57.         }
  58.         break;
  59.      
  60.       case 'insert':
  61.         db_query("INSERT INTO {uc_imis_pricing} (vid, nid, default_class) VALUES (%d, %d, '%s')", $node->vid, $node->nid, $node->default_class);
  62.         break;
  63.        
  64.       case 'update':
  65.         db_query("UPDATE {uc_imis_pricing} SET default_class = '%s' WHERE vid = %d", $node->default_class, $node->vid);        
  66.         break;
  67.     }
  68.   }
  69. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.