コード例 #1
0
ファイル: SavedRecords.php プロジェクト: navtis/xerxes
 /**
  * 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  inserted id
  */
 public function addRecord($username, $source, $id, Record $objXerxesRecord)
 {
     $arrValues = array();
     $iYear = (int) $objXerxesRecord->getYear();
     $strTitle = $objXerxesRecord->getMainTitle();
     $strSubTitle = $objXerxesRecord->getSubTitle();
     if ($strSubTitle != "") {
         $strTitle .= ": " . $strSubTitle;
     }
     $strSQL = "INSERT INTO xerxes_records \r\n\t\t\t( source, original_id, timestamp, username, nonsort, title, author, year, format, record_type, marc )\r\n\t\t\tVALUES \r\n\t\t\t( :source, :original_id, :timestamp, :username, :nonsort, :title, :author, :year, :format, :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->format()->getInternalFormat();
     ##### xerxes 1 transition hack  @todo remove this
     if ($objXerxesRecord instanceof Summon\Record && $this->registry->getConfig('XERXES_1_TRANS', false)) {
         $link_resolver = $this->registry->getConfig("LINK_RESOLVER_ADDRESS", true);
         $sid = $this->registry->getConfig("APPLICATION_SID", false, "calstate.edu:xerxes");
         $objXerxesRecord = new \Xerxes_TransRecord($objXerxesRecord, $link_resolver, $sid);
     }
     ###### end hack
     $arrValues[":marc"] = serialize($objXerxesRecord);
     $arrValues[":record_type"] = "xerxes_record";
     $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 $objXerxesRecord->id;
 }
コード例 #2
0
 /**
  * Add a record to the user's saved record space.
  *
  * @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 Record $xerxes_record	 xerxes record object to save
  * @return int  inserted id
  */
 public function addRecord($username, $source, $id, Record $xerxes_record)
 {
     $arrValues = array();
     $iYear = (int) $xerxes_record->getYear();
     $strTitle = $xerxes_record->getMainTitle();
     $strSubTitle = $xerxes_record->getSubTitle();
     if ($strSubTitle != "") {
         $strTitle .= ": " . $strSubTitle;
     }
     $strSQL = "INSERT INTO xerxes_records \r\n\t\t\t( source, original_id, timestamp, username, nonsort, title, author, year, format, record_type, marc )\r\n\t\t\tVALUES \r\n\t\t\t( :source, :original_id, :timestamp, :username, :nonsort, :title, :author, :year, :format, :record_type, :marc)";
     $arrValues[":source"] = $source;
     $arrValues[":original_id"] = $id;
     $arrValues[":timestamp"] = date("Y-m-d H:i:s");
     $arrValues[":username"] = $username;
     $arrValues[":nonsort"] = $xerxes_record->getNonSort();
     $arrValues[":title"] = substr($strTitle, 0, 90);
     $arrValues[":author"] = $xerxes_record->getPrimaryAuthor(true);
     $arrValues[":year"] = $iYear;
     $arrValues[":format"] = $xerxes_record->format()->getReadableNormalizedFormat();
     $arrValues[":marc"] = serialize($xerxes_record);
     $arrValues[":record_type"] = "xerxes_record";
     return $this->insert($strSQL, $arrValues, true);
 }