public function execute()
    {
        if (!$this->isReady()) {
            throw new LogicException('Collection is not ready');
        }

        if (is_callable($this->pre_execute_callback)) {
            $ids = $this->executeIds();

            if ($ids_count = count($ids)) {
                call_user_func($this->pre_execute_callback, $ids);

                if ($ids_count > 1000) {
                    $sql = $this->getSelectSql(); // Don't escape more than 1000 ID-s using DB::escape(), let MySQL do the dirty work instead of PHP
                } else {
                    $escaped_ids = $this->connection->escapeValue($ids);

                    $sql = "SELECT * FROM {$this->getTableName()} WHERE id IN ($escaped_ids) ORDER BY FIELD (id, $escaped_ids)";
                }

                return $this->pool->findBySql($this->getType(), $sql);
            }

            return null;
        } else {
            return $this->pool->findBySql($this->getType(), $this->getSelectSql());
        }
    }
public function execute()
    {
        if (!$this->isReady()) {
            throw new LogicException('Collection is not ready');
        }

        if (is_callable($this->pre_execute_callback)) {
            $ids = $this->executeIds();

            if ($ids_count = count($ids)) {
                call_user_func($this->pre_execute_callback, $ids);

                if ($ids_count > 1000) {
                    $sql = $this->getSelectSql(); // Don't escape more than 1000 ID-s using DB::escape(), let MySQL do the dirty work instead of PHP
                } else {
                    $escaped_ids = $this->connection->escapeValue($ids);

                    $sql = "SELECT * FROM {$this->getTableName()} WHERE id IN ($escaped_ids) ORDER BY FIELD (id, $escaped_ids)";
                }

                return $this->pool->findBySql($this->getType(), $sql);
            }

            return null;
        } else {
            return $this->pool->findBySql($this->getType(), $this->getSelectSql());
        }
    }
public function execute ( ) { if ( ! $ this -> isReady ( ) ) { throw new LogicException ( 'Collection is not ready' ) ; } if ( is_callable ( $ this -> pre_execute_callback ) ) { $ ids = $ this -> executeIds ( ) ; if ( $ ids_count = count ( $ ids ) ) { call_user_func ( $ this -> pre_execute_callback , $ ids ) ; if ( $ ids_count > 1000 ) { $ sql = $ this -> getSelectSql ( ) ; // Don't escape more than 1000 ID-s using DB::escape(), let MySQL do the dirty work instead of PHP } else { $ escaped_ids = $ this -> connection -> escapeValue ( $ ids ) ; $ sql = "SELECT * FROM {$this->getTableName()} WHERE id IN ($escaped_ids) ORDER BY FIELD (id, $escaped_ids)" ; } return $ this -> pool -> findBySql ( $ this -> getType ( ) , $ sql ) ; } return null ; } else { return $ this -> pool -> findBySql ( $ this -> getType ( ) , $ this -> getSelectSql ( ) ) ; } }
Run the query and return DB result.

@return ResultInterface|EntityInterface[]
Run the query and return DB result .