public function countImageReferences($uri)
{
$path = $this->redecorator->redecorateFromSource($uri);
$connection = $this->getConnection();
$selectQuery = $connection->createSelectQuery();
$selectQuery->select($selectQuery->expr->count($connection->quoteColumn('id')))->from($connection->quoteTable('ezimagefile'))->where($selectQuery->expr->like($connection->quoteColumn('filepath'), $selectQuery->bindValue($path . '%')));
$statement = $selectQuery->prepare();
$statement->execute();
return (int) $statement->fetchColumn();
}