Announcement

Collapse
No announcement yet.

ORM : selectBuilderFactory + where + Cond

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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 ?


  • #2
    Hi Item,

    You can chain where calls.

    PHP Code:
    $nomenclatures $this->em->getRDBRepository('Nomenclature')
        ->
    clone($query)
        ->
    where($where)
        ->
    where(
            
    Cond::and( ... )
        )
        ->
    find();​ 

    Comment


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