How to get a list of all users in ORM?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • roman042
    Member
    • Jun 2017
    • 64

    How to get a list of all users in ORM?

    How to get a list of all users in ORM?

    $this->getEntityManager()->getRepository('User')->find()

    This method returns an empty array...
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    sorry, can't reproduce. need more information
    (rebuild, check the log, file path, method)

    Comment

    • roman042
      Member
      • Jun 2017
      • 64

      #3
      There are no errors in the error logs

      In this example, I'm trying to get the json line in the description field:

      namespace Espo\Jobs;

      use \Espo\Core\Exceptions;

      class TEstJobs extends \Espo\Core\Jobs\Base
      {
      public function run()
      {

      $whereClause = array(
      'name' => "1"
      );

      $tokenList = $this->getEntityManager()->getRepository('Meeting')->where($whereClause)->limit(0, 500)->find();
      foreach ($tokenList as $token) {
      $token->set('description', json_encode($this->getEntityManager()->getRepository('User')->find()));
      $this->getEntityManager()->saveEntity($token);
      }
      }
      }

      From other directories, without problems I receive the data

      Example:

      namespace Espo\Jobs;

      use \Espo\Core\Exceptions;

      class TEstJobs extends \Espo\Core\Jobs\Base
      {
      public function run()
      {

      $whereClause = array(
      'name' => "1"
      );

      $tokenList = $this->getEntityManager()->getRepository('Meeting')->where($whereClause)->limit(0, 500)->find();
      foreach ($tokenList as $token) {
      $token->set('description', json_encode($this->getEntityManager()->getRepository('Case')->find()));
      $this->getEntityManager()->saveEntity($token);
      }
      }
      }

      /

      Comment

      • tanya
        Senior Member
        • Jun 2014
        • 4308

        #4
        check json_last_error_msg()
        for debug mode better to use $this->getEntityManager()->getRepository('User')->find()->toArray()

        Comment

        • roman042
          Member
          • Jun 2017
          • 64

          #5
          So works:
          $this->getEntityManager()->getRepository('User')->find()->toArray()


          json_last_error_msg show "No error"

          Comment

          Working...