public function findByName($name, $create = true)
    {
        $query = $this->dm->createQueryBuilder('Organizations\Entity\OrganizationName')->hydrate(false)->field('name')->equals($name)->select("_id");
        $result = $query->getQuery()->execute()->toArray(false);
        if (empty($result) && $create) {
            $repositoryNames = $this->dm->getRepository('Organizations\Entity\OrganizationName');
            $entityName = $repositoryNames->create();
            $entityName->setName($name);
            $entity = $this->create();
            $entity->setOrganizationName($entityName);
            $this->store($entity);
            $organizations = array($entity);
        } else {
            $idName = $result[0]['_id'];
            $organizations = $this->findBy(array('organizationName' => $idName));
        }
        return $organizations;
    }
public function findByName($name, $create = true)
    {
        $query = $this->dm->createQueryBuilder('Organizations\Entity\OrganizationName')->hydrate(false)->field('name')->equals($name)->select("_id");
        $result = $query->getQuery()->execute()->toArray(false);
        if (empty($result) && $create) {
            $repositoryNames = $this->dm->getRepository('Organizations\Entity\OrganizationName');
            $entityName = $repositoryNames->create();
            $entityName->setName($name);
            $entity = $this->create();
            $entity->setOrganizationName($entityName);
            $this->store($entity);
            $organizations = array($entity);
        } else {
            $idName = $result[0]['_id'];
            $organizations = $this->findBy(array('organizationName' => $idName));
        }
        return $organizations;
    }
public function findByName ( $ name , $ create = true ) { $ query = $ this -> dm -> createQueryBuilder ( 'Organizations\Entity\OrganizationName' ) -> hydrate ( false ) -> field ( 'name' ) -> equals ( $ name ) -> select ( "_id" ) ; $ result = $ query -> getQuery ( ) -> execute ( ) -> toArray ( false ) ; if ( empty ( $ result ) && $ create ) { $ repositoryNames = $ this -> dm -> getRepository ( 'Organizations\Entity\OrganizationName' ) ; $ entityName = $ repositoryNames -> create ( ) ; $ entityName -> setName ( $ name ) ; $ entity = $ this -> create ( ) ; $ entity -> setOrganizationName ( $ entityName ) ; $ this -> store ( $ entity ) ; $ organizations = array ( $ entity ) ; } else { $ idName = $ result [ 0 ] [ '_id' ] ; $ organizations = $ this -> findBy ( array ( 'organizationName' => $ idName ) ) ; } return $ organizations ; }
Find a organizations by an name

@param String $name
@param boolean $create
@return array
Find a organizations by an name