Beispiel #1
0
 /**
  * Add a record to the user's saved record space. $objXerxesRecord will be
  * updated with internal db id and original id.. 
  *
  * @param string $username					username to save the record under
  * @param string $source					name of the source database
  * @param string $id						identifier for the record
  * @param Xerxes_Record $objXerxesRecord	xerxes record object to save
  * @return int  status
  */
 public function addRecord($username, $source, $id, Xerxes_Record $objXerxesRecord)
 {
     $arrValues = array();
     $iRefereed = 0;
     $iYear = (int) $objXerxesRecord->getYear();
     $strTitle = $objXerxesRecord->getMainTitle();
     $strSubTitle = $objXerxesRecord->getSubTitle();
     if ($strSubTitle != "") {
         $strTitle .= ": " . $strSubTitle;
     }
     // peer-reviwed look-up
     if ($objXerxesRecord->getISSN() != null) {
         $arrResults = $this->getRefereed($objXerxesRecord->getISSN());
         if (count($arrResults) > 0) {
             $iRefereed = 1;
         }
     }
     $strSQL = "INSERT INTO xerxes_records \r\n\t\t\t( source, original_id, timestamp, username, nonsort, title, author, year, format, refereed, record_type, marc )\r\n\t\t\tVALUES \r\n\t\t\t( :source, :original_id, :timestamp, :username, :nonsort, :title, :author, :year, :format, :refereed, :record_type, :marc)";
     $arrValues[":source"] = $source;
     $arrValues[":original_id"] = $id;
     $arrValues[":timestamp"] = date("Y-m-d H:i:s");
     $arrValues[":username"] = $username;
     $arrValues[":nonsort"] = $objXerxesRecord->getNonSort();
     $arrValues[":title"] = substr($strTitle, 0, 90);
     $arrValues[":author"] = $objXerxesRecord->getPrimaryAuthor(true);
     $arrValues[":year"] = $iYear;
     $arrValues[":format"] = $objXerxesRecord->getFormat();
     $arrValues[":refereed"] = $iRefereed;
     $arrValues[":marc"] = serialize($objXerxesRecord);
     $arrValues[":record_type"] = "xerxes_record";
     $status = $this->insert($strSQL, $arrValues);
     // get the internal xerxes record id for the saved record, and fill record
     // with it, so caller can use.
     $getIDSql = "SELECT id FROM xerxes_records WHERE original_id = :original_id";
     $getIDParam = array(":original_id" => $id);
     $getIDResults = $this->select($getIDSql, $getIDParam);
     $objXerxesRecord->id = $getIDResults[0]["id"];
     $objXerxesRecord->original_id = $id;
     return $status;
 }