/**
  * @param array $primaryKey
  * @param EntityInterface $entity
  * @return boolean
  * @throws \PDOException
  */
 private function updateExisting(array $primaryKey, EntityInterface $entity)
 {
     $query = 'UPDATE `' . $entity->getTableName() . '` SET';
     foreach ($entity->getSetKeys() as $field) {
         $query .= '`' . $field . '` = ';
         $value = is_null($entity->get($field)) ? 'NULL, ' : '\'' . $entity->get($field) . '\', ';
         $query .= $value;
     }
     $query = substr($query, 0, -2);
     $query .= ' WHERE ';
     foreach ($primaryKey as $idx => $key) {
         $query .= '`' . $idx . '` = \'' . $key . '\' AND ';
     }
     $query = substr($query, 0, -5);
     $query .= ';';
     $query = $this->pdo->getPdo()->query($query);
     if (!$query) {
         $errorInfo = $this->pdo->getPdo()->errorInfo();
         throw new \PDOException($errorInfo[2], $errorInfo[0]);
     }
     return $query->execute();
 }