public function updateDocument(Path $p, $contentType)
{
$currentVersion = $this->getVersion($p);
if (null === $currentVersion) {
$newVersion = '1:' . $this->io->getRandom();
$stmt = $this->db->prepare(sprintf('INSERT INTO %s (path, content_type, version) VALUES(:path, :content_type, :version)', $this->prefix . 'md'));
} else {
$explodedData = explode(':', $currentVersion);
$newVersion = sprintf('%d:%s', $explodedData[0] + 1, $this->io->getRandom());
$stmt = $this->db->prepare(sprintf('UPDATE %s SET version = :version, content_type = :content_type WHERE path = :path', $this->prefix . 'md'));
}
$stmt->bindValue(':path', $p->getPath(), PDO::PARAM_STR);
$stmt->bindValue(':content_type', $contentType, PDO::PARAM_STR);
$stmt->bindValue(':version', $newVersion, PDO::PARAM_STR);
$stmt->execute();
if (1 !== $stmt->rowCount()) {
throw new MetadataStorageException('unable to update node');
}
}