Doctrine\ORM\EntityManager::createQueryBuilder PHP Method

createQueryBuilder() public method

Create a QueryBuilder instance
public createQueryBuilder ( ) : Doctrine\ORM\QueryBuilder
return Doctrine\ORM\QueryBuilder $qb
    public function createQueryBuilder()
    {
        return new QueryBuilder($this);
    }

Usage Example

コード例 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->em = $this->container->getDoctrine()->getManager();
     /* @var $em EntityManager */
     $this->em->beginTransaction();
     $entities = array('CmsAuthentication:User', 'CmsAuthentication:Group', 'Cms:ApplicationLocalizationParameter', 'Cms:BlockPropertyMetadata', 'Cms:ReferencedElement\\ReferencedElementAbstract', 'Cms:BlockProperty', 'Cms:Abstraction\\Block', 'Cms:Abstraction\\PlaceHolder', 'Cms:LocalizationTag', 'Cms:Abstraction\\Localization', 'Cms:Abstraction\\RedirectTarget', 'Cms:PageLocalizationPath', 'Cms:Page', 'Cms:EditLock', 'Cms:TemplateLayout', 'Cms:Template', 'Cms:FileProperty', 'Cms:ImageSize', 'Cms:Image', 'Cms:File', 'Cms:Folder', 'Cms:FilePath');
     if ($input->getOption('clear')) {
         foreach ($entities as $entity) {
             //todo: also clean audit tables here
             $this->em->createQueryBuilder()->delete($entity)->getQuery()->execute();
         }
     }
     $dataFile = $this->container->getParameter('directories.project_root') . DIRECTORY_SEPARATOR . $input->getArgument('filename');
     if (!is_file($dataFile)) {
         throw new \RuntimeException(sprintf('The file [%s] does not exists.', $dataFile));
     }
     $this->dataDir = dirname($dataFile);
     //todo: validate it
     $data = Yaml::parse(file_get_contents($dataFile));
     //we need to maintain creation order
     $sections = array('group', 'user', 'image', 'template', 'page', 'pageLocalization');
     foreach ($sections as $section) {
         foreach ($data[$section] as $name => $definition) {
             $this->createEntity($section, $name, $definition);
         }
     }
     $this->em->flush();
     $this->em->commit();
 }
All Usage Examples Of Doctrine\ORM\EntityManager::createQueryBuilder