function getCustomFields($mbrid)
 {
     # KLUDGE to make sure we don't clobber the results handle
     # when we're called from fetchmember().
     # FIXME - redo query stuff to avoid this issue
     $q = new Query();
     $q->connect();
     $sql = $q->mkSQL('select * from member_fields where mbrid=%N', $mbrid);
     $rows = $q->exec($sql);
     $fields = array();
     foreach ($rows as $r) {
         $fields[$r['code']] = $r['data'];
     }
     return $fields;
 }