.scripts/symbiota.php
/**
   * Step 4 - Cross-Reference with Database.
   *
   * Initially looks if the id is within the database, and if so, updates the
   * fields to match Symbiota, otherwise, insert new data.
   */
Step 4 - Cross-Reference with Database.
Initially looks if the id is within the database, and if so, updates the
fields to match Symbiota, otherwise, insert new data.
Step 4 - Cross - Reference with Database . Initially looks if the id is within the database and if so updates the fields to match Symbiota otherwise insert new data .
public function manipulateDatabase() {
    $this->logger("Manipulating database.");
    foreach ($this->data as $number=>$record) {
      $record["id"] = trim((string) $record["id"]);
      if ($record["id"] === "") {
        continue;
      }
      $prepare = $this->database->prepare("
        SELECT *
        FROM   plants
        WHERE  id = :id
        LIMIT  1
      ");
      $prepare->execute(array(":id" => $record["id"]));
      $results = (array) $prepare->fetchObject();
      if (array_key_exists("id", $results)) {
        $this->logger("Updating " . $record["id"]);
        $this->updateDatabase($results, $record);
        unset($this->deletions[array_search(intval($record["id"]), $this->deletions)]);
      } else {
        $this->logger("Inserting " . $record["id"]);
        $this->insertDatabase($record);
      }
    }
  }
public function manipulateDatabase ( ) { $ this -> logger ( " Manipulating database. " ) ; foreach ( $ this -> data as $ number => $ record ) { $ record [ " id " ] = trim ( ( string ) $ record [ " id " ] ) ; if ( $ record [ " id " ] === " " ) { continue ; } $ prepare = $ this -> database -> prepare ( " 
        SELECT *
        FROM   plants
        WHERE  id = :id
        LIMIT  1
       " ) ; $ prepare -> execute ( array ( " :id " => $ record [ " id " ] ) ) ; $ results = ( array ) $ prepare -> fetchObject ( ) ; if ( array_key_exists ( " id " , $ results ) ) { $ this -> logger ( " Updating  " . $ record [ " id " ] ) ; $ this -> updateDatabase ( $ results , $ record ) ; unset ( $ this -> deletions [ array_search ( intval ( $ record [ " id " ] ) , $ this -> deletions ) ] ) ; } else { $ this -> logger ( " Inserting  " . $ record [ " id " ] ) ; $ this -> insertDatabase ( $ record ) ; } } }
Step 4 - Cross-Reference with Database.
Step 4 - Cross - Reference with Database .
// Update the database. // Remove the id from the deletion array to signal that this id still // exists remotely. // Insert into the database.