Just get where

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • codeboy
    Senior Member
    • May 2018
    • 112

    Just get where

    I want to get only the WHERE part of the SQL output. Because I will add "where" as to pure php.

    for example; WHERE assigned_status = 'Okay'
    like this

    Code:
    $sql = $this->getEntityManager()->getQuery()->createSelectQuery('Meeting', $selectParams);
    $sth = $pdo->prepare($sql);
    $sth->execute();
    Last edited by codeboy; 05-16-2018, 08:01 AM.
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2

    EspoCRM – Open Source CRM Application. Contribute to espocrm/espocrm development by creating an account on GitHub.

    Comment

    • codeboy
      Senior Member
      • May 2018
      • 112

      #3
      Yes, I see, I use it. But I do not want it to be "SELECT * FROM meeting". This function creates them. Because it wants an entity. I just need "WHERE".

      Comment

      • tanya
        Senior Member
        • Jun 2014
        • 4308

        #4
        If you spend 2 minutes for reading the code, you will see, how is built each part of select query, wherePart as well.

        Comment

        • codeboy
          Senior Member
          • May 2018
          • 112

          #5
          I could not. Would you show me a little sample, please?

          Comment

          • tanya
            Senior Member
            • Jun 2014
            • 4308

            #6
            $whereClause = $params['whereClause'];
            if (empty($whereClause)) {
            $whereClause = array();
            }
            if (!$deleted) {
            $whereClause = $whereClause + array('deleted' => 0);
            }
            if (empty($params['joins'])) {
            $params['joins'] = array();
            }
            if (empty($params['leftJoins'])) {
            $params['leftJoins'] = array();
            }
            if (empty($params['customJoin'])) {
            $params['customJoin'] = '';
            }
            $wherePart = $this->getEntityManager()->getQuery()->getWhere($entity, $whereClause, 'AND', $params);
            $where = "WHERE " . $wherePart;


            copied from the the shared file....

            Comment

            • codeboy
              Senior Member
              • May 2018
              • 112

              #7
              Very big thanks
              Argument 1 passed to Espo\\ORM\\DB\\Query\\Base::getWhere() must implement interface Espo\\ORM\\IEntity, string given, called

              because I use string
              Code:
              $this->getEntityManager()->getQuery()->getWhere('Meeting' ,$whereClause, 'AND', $params);
              What does this mean tanya ?

              Comment

              • tanya
                Senior Member
                • Jun 2014
                • 4308

                #8
                means, the method waits for an object (of Meeting Entity)

                Comment

                • codeboy
                  Senior Member
                  • May 2018
                  • 112

                  #9
                  Yeah, I check the codes you sent. I tried to do this. But it gives me a mistake. I'm on the custom report page.

                  Comment

                  • codeboy
                    Senior Member
                    • May 2018
                    • 112

                    #10
                    Thanks, I solved tanya.
                    Last edited by codeboy; 05-16-2018, 11:09 AM.

                    Comment

                    Working...