ORM : selectBuilderFactory + where + Cond

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • item
    Active Community Member
    • Mar 2017
    • 1476

    ORM : selectBuilderFactory + where + Cond

    Hi,
    i don't find how i can do "combine" theses query in one :


    PHP Code:
    
            $where = [
                'active' => true,
                'hidden' => false,
                'professionId' => $user->get('professionId'),
            ];
    
            $query = $this->selectBuilderFactory->create()->from('Nomenclature')
                ->withWhere(
                    (new ItemBuilder)
                        ->setAttribute('qualified')
                        ->setType('arrayAnyOf')
                        ->setValue( [$user->get('qualified')] )
                        ->build()
                    )
                ->build();
            $nomenclatures = $this->em->getRDBRepository('Nomenclature')->clone($query)->where($where)->find();
    And then need this too in the query :

    PHP Code:
    
             Cond::and(
                                    Cond::or(
                                        Cond::equal(Cond::column('dend') , null ),
                                        Cond::greaterOrEqual(Cond::column('dend'), $meeting->get('date'))
                                    ),
                                    Cond::and(
                                        Cond::lessOrEqual(Cond::column('dbegin'), $meeting->get('date') ),
                                        Cond::greaterOrEqual(Cond::column('dend'), $meeting->get('date'))
                                        Cond::equal(Cond::column('type'), 'Internal'),
                                        Cond::equal(Cond::column('contactId'), $contact->getId() ),
                                    )
                                )​​ 
    
    just for information, maybe some value can be "empty or null" (dend for sample)
    is possible ?

    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​
  • yuri
    Member
    • Mar 2014
    • 8453

    #2
    Hi Item,

    You can chain where calls.

    PHP Code:
    $nomenclatures = $this->em->getRDBRepository('Nomenclature')
        ->clone($query)
        ->where($where)
        ->where(
            Cond::and( ... )
        )
        ->find();
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment


    • item
      item commented
      Editing a comment
      Thank you Yuri...
Working...