/**
  * Removes a project from the database.
  *
  * @param \commpress\Cli\Entity\Project $project
  *      The project to remove.
  *
  * @throws \commpress\Cli\Service\Database\Exception\DatabaseQueryException
  *      If something goes wrong.
  */
 public function removeProject(Project $project)
 {
     $query = sprintf('DELETE FROM projects WHERE %s = :id', Project::FIELD_ID);
     $stmt = $this->database->prepare($query);
     $stmt->bindValue(':' . Project::FIELD_ID, $project->getId());
     $result = $stmt->execute();
     $stmt->close();
     if (!$result) {
         throw new DatabaseQueryException(sprintf('Failed to remove project [ id: %d, acronym: %s ] from database.', $project->getId(), $project->getShortName()));
     }
 }
 /**
  * Checks if the project by id exists already in the database.
  *
  * @return bool
  *      TRUE if the project is stored in the database, otherwise false.
  */
 public function entityExists()
 {
     // Before we ask the database we want to make sure we have an id.
     if ($this->project->getId() == null) {
         // No database request is needed in this case.
         return false;
     }
     // Define the query.
     $query = sprintf('SELECT COUNT(id) AS num FROM projects WHERE %s = :id', Project::FIELD_ID);
     // Get the database instance.
     $database = Application::getDatabase();
     // Prepare the statement.
     $stmt = $database->prepare($query);
     $stmt->bindValue(':id', $this->project->getId());
     // Get the result from statement execution.
     $result = $stmt->execute()->fetchArray(SQLITE3_ASSOC);
     // Close the statement to free memory.
     $stmt->close();
     // Check if the project was found.
     if ($result['num'] >= 1) {
         return true;
     }
     return false;
 }