Get the complete sql

@since 2.0.5
19912
public function get_sql( $sql ) {

		global $wpdb;

		if ( empty( $sql ) ) {
			$sql = $this->sql;
		}

		/**
		 * Allow SQL query to be manipulated.
		 *
		 * @param string   $sql       SQL Query string.
		 * @param PodsData $pods_data PodsData object.
		 *
		 * @since 2.7.0
		 */
		$sql = apply_filters( 'pods_data_get_sql', $sql, $this );

		$sql = str_replace( array( '@wp_users', '@wp_' ), array( $wpdb->users, $wpdb->prefix ), $sql );

		$sql = str_replace( '{prefix}', '@wp_', $sql );
		$sql = str_replace( '{/prefix/}', '{prefix}', $sql );

		return $sql;
	}
1006863
public function get_select_sql( $tables, $where = null, $fields = null, $limit = null, $offset = null, $order_by = null, $group_by = null, $for_update = false ) {
		$as = null;
		if ( is_array( $tables ) ) {
			if ( empty( $tables ) ) {
				return false;
			}
			$table = array_shift( $tables );
			$join  = $tables;
			if ( count( $table ) > 1 ) {
				$as = $table[1];
			}
			$table = $table[0];
		} else {
			$table = $tables;
			$join  = null;
		}
		if ( ! isset( $this->table_defines[ $table ] ) ) {
			return false;
		}

		$columns = $this->table_defines[ $table ]['columns'];

		! is_array( $where ) and $where = [];
		if ( $this->is_logical( $this->table_defines[ $table ] ) ) {
			$where['deleted_at'] = null;
		}

		list( $conditions, $values ) = $this->build_conditions( $where, $columns );
		$table  = $this->get_table( $table );
		$fields = $this->build_fields( $fields, $columns );
		$sql    = "SELECT {$fields} FROM $table";
		if ( isset( $as ) ) {
			$sql .= " AS $as";
		}
		$sql .= $this->build_join( $join );
		if ( ! empty( $conditions ) ) {
			$sql .= " WHERE $conditions";
		}
		$sql .= $this->build_group_by( $group_by, $columns );
		$sql .= $this->build_order_by( $order_by, $columns );
		$sql .= $this->build_limit( $limit, $offset );
		if ( $for_update ) {
			$sql .= ' FOR UPDATE';
		}

		return $this->prepare( $sql, $values );
	}
704318
public function complete_sql($sql = null, array $params = [], array $extra_params = [])
    {
        if (func_num_args()) {
            if (isset($extra_params['page']))
                $this->page = $extra_params['page'];
            if (isset($extra_params['perPage']))
                $this->limit = $extra_params['perPage'];
            if (isset($extra_params['offset']))
                $this->offset = $extra_params['offset'];
            if ($this->page && $this->limit)
                $this->will_paginate = true;
                
            $this->complete_sql = [$sql, $params];
            return $this;
        } else
            return $this->complete_sql;
    }
1088643
def get_sql(self):
        
        sql = ''
        if self.limit and self.limit > 0:
            sql += 'LIMIT {0} '.format(self.limit)
        if self.offset and self.offset > 0:
            sql += 'OFFSET {0} '.format(self.offset)
        return sql
748812
public function findAllBySql($sql,$params=array())
	{
		Yii::trace(get_class($this->_joinTree->model).'.findAllBySql() eagerly','system.db.ar.CActiveRecord');
		if(($rows=$this->_builder->createSqlCommand($sql,$params)->queryAll())!==array())
		{
			$baseRecords=$this->_joinTree->model->populateRecords($rows,false);
			$this->_joinTree->findWithBase($baseRecords);
			$this->_joinTree->afterFind();
			$this->destroyJoinTree();
			return $baseRecords;
		}
		else
		{
			$this->destroyJoinTree();
			return array();
		}
	}
1104051
public function getQuery(): string
    {
        $sql = $this->getSql();

        $sql = str_replace(['%', '?'], ['%%', '"%s"'], $sql);

        // replace mask by data
        return vsprintf($sql, $this->getParams());
    }
1215568
public String getSQL()
    {
        final StringBuilder cmd = new StringBuilder().append(" ")
            .append(Context.getDbType().getSQLPart(SQLPart.SELECT)).append(" ");
        if (distinct) {
            cmd.append(Context.getDbType().getSQLPart(SQLPart.DISTINCT)).append(" ");
        }
        boolean first = true;
        for (final Column column : columns) {
            if (first) {
                first = false;
            } else {
                cmd.append(Context.getDbType().getSQLPart(SQLPart.COMMA));
            }
            column.appendSQL(cmd);
        }
        cmd.append(" ").append(Context.getDbType().getSQLPart(SQLPart.FROM)).append(" ");
        first = true;
        for (final FromTable fromTable : fromTables) {
            fromTable.appendSQL(first, cmd);
            if (first) {
                first = false;
            }
        }
        cmd.append(" ");
        boolean whereAdded = false;
        for (final SQLSelectPart part : parts) {
            part.appendSQL(cmd);
            cmd.append(" ");
            whereAdded = whereAdded || !whereAdded && SQLPart.WHERE.equals(part.sqlpart);
        }

        if (where != null) {
            where.setStarted(whereAdded);
            where.appendSQL(tablePrefix, cmd);
        }

        if (order != null) {
            order.appendSQL(tablePrefix, cmd);
        }
        return cmd.toString();
    }
446785
public function getQuery()
    {
        $sql = $this->prepareSelectString();
        $sql .= $this->prepareJoinString();
        $sql .= $this->prepareWhereString();
        $sql .= $this->prepareGroupByString();
        $sql .= $this->prepareHavingString();
        $sql .= $this->prepareOrderByString();
        $sql .= $this->prepareLimitString();

        return $sql;
    }
589815
def get_sql(self):
        
        # reset arg index and args
        self.arg_index = 0
        self.args = {}

        # build the WHERE sql portion if needed
        if len(self.wheres):
            where = self.build_where_part(self.wheres)
            return 'WHERE {0} '.format(where)
        return ''
239764
protected function _getQuery()
    {
        $sSelTable = $this->_getViewName('oxattribute');
        $sArtId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('oxid');

        return " from $sSelTable left join oxcategory2attribute on oxcategory2attribute.oxattrid = $sSelTable.oxid " .
                 "where oxobjectid = " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote($sArtId) . " ";
    }
829344
public function get_sql_where() {
        list($where, $params) = parent::get_sql_where();
        $where = preg_replace('/firstname/', 'u.firstname', $where);
        $where = preg_replace('/lastname/', 'u.lastname', $where);
        return [$where, $params];
    }
1179610
public function getTablesFromSQL($sql) {
        $p      = '/CREATE\s+TABLE\s+(IF\s+NOT\s+EXISTS\s+)?([^\(]+)/mi';
        $tables = [];
        $views  = [];
        if (preg_match_all($p, $sql, $ms, PREG_SET_ORDER)) {
            foreach ($ms as $m) {
                if (count($m) == 3) {
                    $table = $m [2];
                } else {
                    $table = $m [1];
                }
                if ($table) {
                    $table     = trim(trim($table, '` '));
                    $tables [] = str_replace('{prefix}', $this->tablePrefix, $table);
                }
            }
        }
        $p = '/CREATE\s+VIEW\s+(IF\s+NOT\s+EXISTS\s+)?(.+?)\s+AS/mi';
        if (preg_match_all($p, $sql, $ms, PREG_SET_ORDER)) {
            foreach ($ms as $m) {
                if (count($m) == 3) {
                    $table = $m [2];
                } else {
                    $table = $m [1];
                }
                if ($table) {
                    $table    = trim(trim($table, '` '));
                    $views [] = str_replace('{prefix}', $this->tablePrefix, $table);
                }
            }
        }

        return ['tables' => $tables, 'views' => $views];
    }
955046
protected function _getQuery()
    {
        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $sId = $myConfig->getRequestParameter('oxid');
        $sSynchId = $myConfig->getRequestParameter('synchoxid');

        $sUserTable = $this->_getViewName('oxuser');

        // category selected or not ?
        if (!$sId) {
            $sQAdd = " from $sUserTable where 1 ";
            if (!$myConfig->getConfigParam('blMallUsers')) {
                $sQAdd .= "and $sUserTable.oxshopid = '" . $myConfig->getShopId() . "' ";
            }
        } elseif ($sSynchId && $sSynchId != $sId) {
            // selected group ?
            $sQAdd = " from oxobject2group left join $sUserTable on $sUserTable.oxid = oxobject2group.oxobjectid ";
            $sQAdd .= " where oxobject2group.oxgroupsid = " . $oDb->quote($sId);
            if (!$myConfig->getConfigParam('blMallUsers')) {
                $sQAdd .= "and $sUserTable.oxshopid = '" . $myConfig->getShopId() . "' ";
            }

            // resetting
            $sId = null;
        } else {
            $sQAdd = " from oxobject2delivery, $sUserTable where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sId);
            $sQAdd .= "and oxobject2delivery.oxobjectid = $sUserTable.oxid and oxobject2delivery.oxtype = 'oxdelsetu' ";
        }

        if ($sSynchId && $sSynchId != $sId) {
            $sQAdd .= "and $sUserTable.oxid not in ( select $sUserTable.oxid from oxobject2delivery, $sUserTable where oxobject2delivery.oxdeliveryid = " . $oDb->quote($sSynchId);
            $sQAdd .= "and oxobject2delivery.oxobjectid = $sUserTable.oxid and oxobject2delivery.oxtype = 'oxdelsetu' ) ";
        }

        return $sQAdd;
    }
65657
public function getAll($sql = null)
    {
        if ($sql) {
            $this->setLastQuery($sql);

            try {
                $results = $this->db->query($sql);
            } catch (\PDOException $e) {
                throw new DatabaseException($e->getMessage() . '<br>' . $this->getLastQuery()[0]);
            }

            return $this->fetchAssoc($results);
        }

        try {
            $results = $this->query();
        } catch (\PDOException $e) {

            throw new DatabaseException($e->getMessage() . '<br>' . $this->getLastQuery()[0]);
        }

        $this->clearQuery();

        return $results->fetchAssoc();
    }
113969
protected function get_searchsql() {
        global $DB;

        $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
        $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
        $params = array(
            'contextlevel' => CONTEXT_COURSECAT,
            'namesearch' => '%'.$this->get_search().'%',
        );

        $select     = " SELECT c.id, c.name, c.visible, c.sortorder, c.description, c.descriptionformat ";
        $from       = " FROM {course_categories} c ";
        $where      = " WHERE ".$DB->sql_like('c.name', ':namesearch', false);
        $orderby    = " ORDER BY c.sortorder";

        return array($select.$ctxselect.$from.$ctxjoin.$where.$orderby, $params);
    }
944325
public function getSQL()
    {
        if ($this->sql !== null && $this->state === self::STATE_CLEAN) {
            return $this->sql;
        }

        switch ($this->type) {
            case self::INSERT:
                $sql = $this->getSQLForInsert();
                break;
            case self::DELETE:
                $sql = $this->getSQLForDelete();
                break;

            case self::UPDATE:
                $sql = $this->getSQLForUpdate();
                break;

            case self::SELECT:
            default:
                $sql = $this->getSQLForSelect();
                break;
        }

        $this->state = self::STATE_CLEAN;
        $this->sql   = $sql;

        return $sql;
    }
619362
public function getWhere()
    {
        $template = "WHERE %s";
        $where = null;
        if (count($this->_sql->conditions->predicates) > 0) {
            $where = trim(
                sprintf($template, $this->_sql->conditions->toString())
            );
        }

        return $where;
    }