Пример #1
0
 /**
  * Checks whether the given managed entity exists in the database.
  *
  * @param  object $entity
  * @return bool
  */
 public function exists($entity)
 {
     $metadata = $this->getMetadata($entity);
     $identifier = $metadata->getIdentifier(true);
     if (empty($identifier)) {
         return false;
     }
     return (bool) $this->connection->fetchColumn('SELECT 1 FROM ' . $metadata->getTable() . ' WHERE ' . $identifier . '=' . $this->connection->quote($metadata->getValue($entity, $identifier, true)));
 }