Returns the SQL of all elements and merges it with already existing
sql statements for the signal slot dispatcher

@param array $sqlString
@return array
968315
public function addDatabaseTablesDefinition(array $sqlString)
    {
        $storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Domain\\Repository\\StorageRepository');
        $json = $storageRepository->load();
        $sql = $this->getSqlByConfiguration($json);
        $mergedSqlString = array_merge($sqlString, $sql);
        return array('sqlString' => $mergedSqlString);
    }
532176
public function getSql(SqlWalker $sqlWalker)
    {
        return  'replace('.$this->stringFirst->dispatch($sqlWalker).','
            .$this->stringSecond->dispatch($sqlWalker).','
            .$this->stringThird->dispatch($sqlWalker).')';
    }
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;
	}
1097597
public static function splitSql($sql)
	{
		$start   = 0;
		$length  = strlen($sql);
		$queries = [];

		foreach (Str::findLiteral(';', $sql) as $queryEndPosition)
		{
			$queries[] = trim(substr($sql, $start, $queryEndPosition - $start + 1));
			$start     = $queryEndPosition + 1;
		}

		// Grab the last query in case it doesn't end with a ';'
		if ($end = trim(substr($sql, $start)))
		{
			$queries[] = $end;
		}

		return $queries;
	}
1079041
public function get_sql_filter($data) {
        global $CFG;
        $value = (int)$data['value'];

        $timenow = round(time(), 100);

        $sql = "id IN (SELECT userid
                         FROM {role_assignments} a
                        WHERE a.contextid=".SYSCONTEXTID." AND a.roleid=$value)";
        return array($sql, array());
    }
62491
public function query($sql)
    {
        $sql = trim($sql);
        if (empty($sql)) {
            $callers = debug_backtrace();
            $msg = "Sorry I don't understand your SQL: " . PHP_EOL . $sql . PHP_EOL . PHP_EOL;
            $msg.= "I have been called by {$callers[1]['class']}::{$callers[1]['function']}";
            throw new \InvalidArgumentException($msg);
        }

        $data = array();
        $this->log->debug($this->logPrefix . 'Query: ' . preg_replace('/\s+/', ' ', $sql));

        $res = $this->sugarDb->query($sql, false);
        // Error in Query
        if (!empty($this->sugarDb->database->error)) {
            throw new \InvalidArgumentException("SQL Error in query: {$this->sugarDb->database->error}");
        }

        // No data to send to the caller
        if (!isset($res->num_rows)) {
            return true;
        }

        // Empty result
        if ($res->num_rows === 0) {
            return array();
        }

        // data to send
        while ($row = $res->fetch_assoc()) {
            $data[] = $row;
        }
        $res->free();

        return $data;
    }
617733
public static function getAll($sql)
    {
        try {
            // return self::$conn->query($sql, PDO::FETCH_ASSOC);
            
            $stmt = self::$conn->prepare($sql);
            $stmt->execute();
            
            // set the resulting array to associative
            $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
            return $result;
        } catch (PDOException $e) {
            echo '<br><span style="color:red;">Line #' . __LINE__ . ' (/X.php) </span> ' . $sql . "</hr>" . $e->getMessage();
        }
    }
1202330
public static function fetchAll($conn, $sql) {
    $conn = is_array($conn) ? self::connect($conn) : $conn;
    $result = $conn->query($sql);
    if (!$result) {
      throw new SqlException("Cannot execute $sql: " . $conn->error);
    }

    $rows = array();
    while ($row = $result->fetch_assoc()) {
      $rows[] = $row;
    }
    $result->free_result();

    return $rows;
  }
827270
public function sql(): string
    {
        if (empty($this->parts)) {
            return '1';
        }
        return (string) \array_reduce(
            $this->parts,
            function (string $sql, array $part): string {
                /** @var string|self $condition */
                $condition = $part['condition'];

                if ($this->isGroup($condition)) {
                    // (...)
                    if (\is_string($condition)) {
                        $statement = '(' . $condition . ')';
                    } else {
                        $statement = '(' . $condition->sql() . ')';
                    }
                } else {
                    // foo = ?
                    $statement = $condition;
                }
                /** @var string $statement */
                $statement = (string) $statement;
                $part['type'] = (string) $part['type'];

                if ($sql) {
                    switch ($part['type']) {
                        case 'AND':
                        case 'OR':
                            $statement = $part['type'] . ' ' . $statement;
                            break;
                        default:
                            throw new RuntimeException(
                                \sprintf('Invalid joiner %s', $part['type'])
                            );
                    }
                }

                return \trim($sql . ' ' . $statement);
            },
            ''
        );
    }
1078572
public function toString()
    {
        if (!$this->_parts['table']) {
            throw new SqlException("Invalid `DROP TABLE` statement, missing `TABLE` clause.");
        }

        return 'DROP TABLE' .
            $this->_buildFlag('IF EXISTS', $this->_parts['ifExists']) .
            $this->_buildChunk($this->dialect()->names($this->_parts['table'])) .
            $this->_buildFlag('CASCADE', $this->_parts['cascade']) .
            $this->_buildFlag('RESTRICT', $this->_parts['restrict']);
    }
40102
public function get_sql_filter($data) {
        static $counter = 0;
        $name = 'ex_simpleselect'.$counter++;

        $value = $data['value'];
        $params = array();
        $field = $this->_field;
        if ($value == '') {
            return '';
        }
        return array("$field=:$name", array($name => $value));
    }
883776
public function toSql(): array
    {
        if (!$this->into) {
            throw new SqlException('Undefined INSERT table.');
        }

        if (!$this->columns and !$this->select) {
            throw new SqlException('Undefined INSERT columns.');
        }

        $params = [];

        $sql = ['INSERT INTO', $this->into, '(' . implode(', ', $this->columns) . ')'];

        if ($this->select) {
            $select = $this->prepareSelect($this->select);

            $sql[] = $select['sql'];

            $params = array_merge($params, $select['params']);
        } else {
            $columnsCount = count($this->columns);

            $valuesCount = count($this->values);

            if ($columnsCount !== $valuesCount) {
                throw new SqlException('INSERT values count does not match.'
                    . ' Expected ' . $columnsCount . ', got ' . $valuesCount . '.');
            }

            $sql[] = 'VALUES ' . $this->prepareBindKeys($this->values);

            $params = array_merge($params, $this->values);
        }

        $sql = implode(' ', $sql);

        return [$sql, $params];
    }
845759
protected function getColumnsSql(array $sql): array
    {
        if (empty($this->columns)) {
            $sql[] = '*';

            return $sql;
        }
        $columns = [];
        foreach ($this->columns as $key => $column) {
            if ($column instanceof Closure) {
                // Sub Select
                $query = new SelectQuery($this->db);
                $column($query);
                $column = new RawExp($query->build(false));
            }
            $columns[] = $column;
        }
        $sql[] = implode(',', $this->quoter->quoteNames($columns));

        return $sql;
    }
668397
public static function xml2array($xmlstring)
    {
        $result = [];
        self::normalizeSimpleXML(simplexml_load_string($xmlstring, null, LIBXML_NOCDATA), $result);

        return $result;
    }
355093
public function getSql()
    {
        $sqlTemplate = "SELECT %s FROM %s %s";
        $fieldsCompiled = implode(',', $this->getFields());
        return trim(sprintf(
            $sqlTemplate,
            $fieldsCompiled,
            $this->getTable(),
            $this->getWhereStatement()
        ));
    }
999242
private function splitTabSql($sql)
    {
        $result = [];
        //find opening bracket, get the prefix along with it
        $openBracketPos = $this->getDelimiterPos($sql, 0, '(');

        if ($openBracketPos === false) {
            trigger_error('[WARNING] can not find opening bracket in table definition');
            return false;
        }

        $prefix = substr($sql, 0, $openBracketPos + 1); // prefix can not be empty, so do not check it, just trim
        $result[] = trim($prefix);
        $body = substr($sql, strlen($prefix)); // fields, indexes and part after closing bracket

        //split by commas, get part by part
        while (($commaPos = $this->getDelimiterPos($body, 0, ',', true)) !== false) {
            $part = trim(substr($body, 0, $commaPos + 1));//read another part and shorten $body
            if ($part) {
                $result[] = $part;
            }
            $body = substr($body, $commaPos + 1);
        }

        // here we have last field (or index) definition + part after closing bracket (ENGINE, ect)
        $closeBracketPos = $this->getDelimiterRightPosition($body, 0, ')');
        if ($closeBracketPos === false) {
            trigger_error('[WARNING] can not find closing bracket in table definition');
            return false;
        }

        // get last field / index definition before closing bracket
        $part = substr($body, 0, $closeBracketPos);
        $result[] = trim($part);

        // get the suffix part along with the closing bracket
        $suffix = substr($body, $closeBracketPos);
        $suffix = trim($suffix);
        if ($suffix) {
            $result[] = $suffix;
        }

        return $result;
    }
725835
public function runQuery($queryString){

		$this->affectedRows = false;
		if($this->dbCharset !== null)
			$queryString = iconv($this->charset, $this->dbCharset . '//IGNORE', $queryString);

		if($this->unbuffered)
			$result = @sqlite_unbuffered_query($this->resource, $queryString, null, $error);
		else
			$result = @sqlite_query($this->resource, $queryString, null, $error);

		if($error && $result === false)
			throw new DriverException($error, sqlite_last_error($this->resource), $queryString);

		$this->affectedRows = @sqlite_changes($this->resource);
		return $result;
	}