select with join, no field in output

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Zuzz
    Member
    • Nov 2023
    • 42

    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.
  • yuri
    Member
    • Mar 2014
    • 8562

    #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
    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

    • Zuzz
      Member
      • Nov 2023
      • 42

      #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

      • yuri
        Member
        • Mar 2014
        • 8562

        #4
        The difference is that DocumentFolder1 starts from an upper case letter. It's supposed to be a lower case.
        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

        Working...