.scripts/contentdm.php
/**
   * Step 3 - Cross-Reference with Database.
   *
   * Initially looks if the pointer is within the database and if so, updates
   * the fields to match CONTENTdm, otherwise, inserts new data.
   */
Step 3 - Cross-Reference with Database.
Initially looks if the pointer is within the database and if so, updates
the fields to match CONTENTdm, otherwise, inserts new data.
Step 3 - Cross - Reference with Database . Initially looks if the pointer is within the database and if so updates the fields to match CONTENTdm otherwise inserts new data .
public function manipulateDatabase() {
    $this->logger("Manipulating database.");
    foreach ($this->content["records"] as $key=>$record) {
      $record["pointer"] = trim((string) $record["pointer"]);
      $prepare = $this->database->prepare("
        SELECT *
        FROM   manuscripts
        WHERE  pointer = :pointer
        LIMIT  1
      ");
      $prepare->execute(array(":pointer" => $record["pointer"]));
      $results = (array) $prepare->fetchObject();
      $record["collection"] = trim(substr($record["collection"], 1));
      $record["parent_object"] = trim((string) $record["parentobject"]);
      unset($record["find"], $record["filetype"], $record["parentobject"]);
      if (array_key_exists("pointer", $results)) {
        $this->logger("Updating " . $record["pointer"]);
        $this->updateDatabase($results, $record);
        unset($this->deletions[array_search(intval($record["pointer"]), $this->deletions)]);
      } else {
        $this->logger("Inserting " . $record["pointer"]);
        $this->insertDatabase($record);
      }
    }
  }
public function manipulateDatabase ( ) { $ this -> logger ( " Manipulating database. " ) ; foreach ( $ this -> content [ " records " ] as $ key => $ record ) { $ record [ " pointer " ] = trim ( ( string ) $ record [ " pointer " ] ) ; $ prepare = $ this -> database -> prepare ( " 
        SELECT *
        FROM   manuscripts
        WHERE  pointer = :pointer
        LIMIT  1
       " ) ; $ prepare -> execute ( array ( " :pointer " => $ record [ " pointer " ] ) ) ; $ results = ( array ) $ prepare -> fetchObject ( ) ; $ record [ " collection " ] = trim ( substr ( $ record [ " collection " ] , 1 ) ) ; $ record [ " parent_object " ] = trim ( ( string ) $ record [ " parentobject " ] ) ; unset ( $ record [ " find " ] , $ record [ " filetype " ] , $ record [ " parentobject " ] ) ; if ( array_key_exists ( " pointer " , $ results ) ) { $ this -> logger ( " Updating  " . $ record [ " pointer " ] ) ; $ this -> updateDatabase ( $ results , $ record ) ; unset ( $ this -> deletions [ array_search ( intval ( $ record [ " pointer " ] ) , $ this -> deletions ) ] ) ; } else { $ this -> logger ( " Inserting  " . $ record [ " pointer " ] ) ; $ this -> insertDatabase ( $ record ) ; } } }
Step 3 - Cross-Reference with Database.
Step 3 - Cross - Reference with Database .
// Convert pointer to a string. // Trim collection. // Convert to parent_object. // Remove the fields not needed in the local database. // Update the database. // Remove the pointer from the deletion array to signal that // this pointer still exists remotely. // Insert into the database.