Announcement

Collapse
No announcement yet.

select with join, no field in output

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

  • select with join, no field in output

    I want to select DocumentFolder with it's parent , but no field in output (screenshot in attach)

    $collection = $entityManager
    ->getRDBRepository('DocumentFolder')
    ->select([
    'id',
    'name',
    'parentId',
    'DocumentFolder1.id',
    ['DocumentFolder1.name', 'name1']
    ])
    ->join(
    'DocumentFolder', // meeting_user table
    'DocumentFolder1', // alias
    [
    'DocumentFolder1.id:' => 'parentId', // join condition
    'deleted' => false, // important
    ],
    )->find();

    $newlistdata = $collection->getValueMapList();​

    How to add field in output ?
    Attached Files
    Last edited by Zuzz; 07-28-2024, 08:07 AM.

  • #2
    Because DocumentFolder entity does not have such a field. Don't use the repository, build a select query and then a PDOStatement. https://docs.espocrm.com/development/orm/#query-builder

    Comment


    • #3
      Please, here the docs example. What is the difference between ['meetingUser.status', 'meetingStatus'] from sample and 'DocumentFolder1.name', 'name1'] ​ from my code ?


      <?php
      $query = $entityManager
      ->getRDBRepository('Meeting')
      ->select([
      'id',
      'name',
      ['meetingUser.status', 'meetingStatus'], // expression and alias
      ])
      ->join(
      'MeetingUser', // meeting_user table
      'meetingUser', // alias
      [
      'meetingUser.meetingId:' => 'id', // join condition
      'meetingUser.deleted' => false, // important
      ],
      )
      ->where([
      'meetingUser.userId' => $user->getId(),
      ])
      ->find();​

      Comment


      • #4
        The difference is that DocumentFolder1 starts from an upper case letter. It's supposed to be a lower case.

        Comment

        Working...
        X