function doQuery($bibid, $tab = "cataloging")
 {
     # reset rowNmbr
     $this->_rowNmbr = 0;
     $this->_currentRowNmbr = 1;
     $this->_rowCount = 1;
     $this->_pageCount = 1;
     $exclude = array("363x", "526x", "583x", "754x", "852x", "856x");
     /***********************************************************
      *  Reading biblio data
      ***********************************************************/
     # setting query that will return all the data in biblio
     $sql = $this->mkSQL("select biblio.*, staff.username " . "from biblio left join staff " . "on biblio.last_change_userid = staff.userid " . "where biblio.bibid = %N ", $bibid);
     if (!$this->_query($sql, $this->_loc->getText("biblioQueryQueryErr1"))) {
         return false;
     }
     $array = $this->_conn->fetchRow();
     $bib = new Biblio();
     $bib->setBibid($array["bibid"]);
     $bib->setCreateDt($array["create_dt"]);
     $bib->setLastChangeDt($array["last_change_dt"]);
     $bib->setLastChangeUserid($array["last_change_userid"]);
     if (isset($array["username"])) {
         $bib->setLastChangeUsername($array["username"]);
     }
     $bib->setMaterialCd($array["material_cd"]);
     $bib->setCollectionCd($array["collection_cd"]);
     $bib->setCallNmbr1($array["call_nmbr1"]);
     $bib->setCallNmbr2($array["call_nmbr2"]);
     $bib->setCallNmbr3($array["call_nmbr3"]);
     if ($array["opac_flg"] == "Y") {
         $bib->setOpacFlg(true);
     } else {
         $bib->setOpacFlg(false);
     }
     /***********************************************************
      *  Reading biblio_field data
      ***********************************************************/
     # setting query that will return all the data in biblio
     $sql = $this->mkSQL("select biblio_field.* " . "from biblio_field " . "where biblio_field.bibid = %N " . "order by tag, subfield_cd ", $bibid);
     if (!$this->_query($sql, $this->_loc->getText("biblioQueryQueryErr2"))) {
         return false;
     }
     /***********************************************************
      *  Adding fields from biblio to Biblio object 
      ***********************************************************/
     foreach ($this->_fieldsInBiblio as $key => $name) {
         $tag = substr($key, 0, 3);
         $subfieldCd = substr($key, 3, 1);
         $subfieldIdx = '';
         if (count($key) > 4) {
             $index = substr($key, 4);
         }
         $this->_addField($tag, $subfieldCd, $array[$name], $bib, $subfieldIdx);
     }
     /***********************************************************
      *  Adding fields from biblio_field to Biblio object 
      ***********************************************************/
     # subfieldIdx will be used to construct index
     $subfieldIdx = 0;
     $saveTag = "";
     $saveSubfield = "";
     while ($array = $this->_conn->fetchRow()) {
         $tag = $array["tag"];
         $subfieldCd = $array["subfield_cd"];
         if ($tab == "opac" and in_array($tag . $subfieldCd, $exclude)) {
             continue;
         }
         # checking for tag and subfield break in order to set the subfield Idx correctly.
         if ($tag == $saveTag and $subfieldCd == $saveSubfield) {
             $subfieldIdx = $subfieldIdx + 1;
         } else {
             $subfieldIdx = 0;
             $saveTag = $tag;
             $saveSubfield = $subfieldCd;
         }
         # setting the index.
         # format is ttts[i] where
         #    t=tag
         #    s=subfield code
         #    i=subfield index if > 0
         # examples: 020a 650a 650a1 650a2
         $index = sprintf("%03d", $tag) . $subfieldCd;
         if ($subfieldIdx > 0) {
             $index = $index . $subfieldIdx;
         }
         $bibFld = new BiblioField();
         $bibFld->setBibid($array["bibid"]);
         $bibFld->setFieldid($array["fieldid"]);
         $bibFld->setTag($array["tag"]);
         $bibFld->setInd1Cd($array["ind1_cd"]);
         $bibFld->setInd2Cd($array["ind2_cd"]);
         $bibFld->setSubfieldCd($array["subfield_cd"]);
         $bibFld->setFieldData($array["field_data"]);
         $bib->addBiblioField($index, $bibFld);
     }
     return $bib;
 }