Announcement

Collapse
No announcement yet.

Espo 5.9.4 problem with ORM - Select Manager

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

  • Espo 5.9.4 problem with ORM - Select Manager

    Hi,

    I found a problem using orm. When I try to use select manager and join another table in response I don't get any columns from join expression.

    PHP Code:
    $entityManager $this->getEntityManager();
            try {
                
    $test $entityManager->getRepository('ProcessedDeclaration')
                    ->
    select(['id''name''date''wasteMass''servicedBy''route.status''account.servicedBy']) // if I skip this, I receive full ProcessedDeclaration object without joined tables columns
                    
    ->join([['Account''account', ['account.id:' => 'id']]])
                    ->
    join([['Route''route', ['route.id:' => 'route_id']]])
                    ->
    join([['WasteTransferCard''wtc', ['wtc.id:' => 'waste_transfer_card_id']]])
                    ->
    join([['Legal,''l', ['l.id:' => 'account.current_legal_id']]]) // tried to name columns in camel case and snake case, the same results
                    
    ->join([['Driver''d', ['d.id:' => 'route.driver_route_id']]])
                    ->
    where([
                         
    'AND' => [
                             
    'wasteMass>' => 0,
                             
    'status' => [
                                 
    "Processed"
                             
    ]
                         ]
                    ])
                    ->
    groupBy('id')
                    ->
    limit(01)
                    ->
    find();
                
    var_dump($test->toArray());
            } catch (
    \Exception $e) {
                
    var_dump($e->getMessage());
            } 

  • #2
    Hi,

    Entity can receive only its defined attributes. Your variable $test is of Entity type.

    Your case is MUCH easier to handle in v6.0.

    In v5 you can't use Repository for your case.

    You need to use raw select params.

    PHP Code:

    $sql 
    $this->getEntityManager()->getQuery()->createSelectQuery('ProcessedDeclaration'$selectParams);

    $sth $pdo->prepare($sql);
    $sth->execute(); 

    Comment


    • #3
      In v6.0:

      PHP Code:

      $selectQuery 
      $entityManager
          
      ->getQueryBuilder()
          ->
      select()
          ->
      from('SomeTable')
          ->
      select( ... )
          ->
      join( ... )
          ->
      build();

      $row $entityManager
          
      ->getQueryExecutor()
          ->
      execute($selectQuery)
          ->
      fetch(); 

      Comment

      Working...
      X