Check for abuse parameters in query
@param string $q - query
435145
public function sqlQueryCheck($q)
    {
        if (\stripos($q, 'union') !== false) {
            dump('UNION usage is limited.');
        }

        if (\stripos($q, ' like \'%\'') !== false) {
            dump('LIKE \'%\' usage is limited.');
        }

        if (\strpos($q, '/*') !== false || \strpos($q, '--') !== false) {
            dump('Comments like \* or -- usage is limited. Query: ' . $q);
        }
    }
784048
static function isWriteQuery($query) {
    $q = " " . strtolower(preg_replace("/\\s/i", " ", $query)) . " ";
    return strpos($q, " update ") !== false ||
      strpos($q, " insert ") !== false ||
      strpos($q, " delete ") !== false ||
      strpos($q, " create table ") !== false ||
      strpos($q, " alter table ") !== false ||
      strpos($q, " drop table ") !== false ||
      strpos($q, " show tables ") !== false ||
      strpos($q, " from migrations ") !== false;
  }
9327
public function initQueryConditions($m, $q)
    {
        if (!isset($m->conditions)) {
            // no conditions are set in the model
            return $q;
        }

        foreach ($m->conditions as $cond) {

            // Options here are:
            // count($cond) == 1, we will pass the only
            // parameter inside where()

            if (count($cond) == 1) {

                // OR conditions
                if (is_array($cond[0])) {
                    foreach ($cond[0] as &$row) {
                        if (is_string($row[0])) {
                            $row[0] = $m->getField($row[0]);
                        }
                    }
                }

                $q->where($cond[0]);
                continue;
            }

            if (is_string($cond[0])) {
                $cond[0] = $m->getField($cond[0]);
            }

            if (count($cond) == 2) {
                if ($cond[0] instanceof Field) {
                    $cond[1] = $this->typecastSaveField($cond[0], $cond[1]);
                }
                $q->where($cond[0], $cond[1]);
            } else {
                if ($cond[0] instanceof Field) {
                    $cond[2] = $this->typecastSaveField($cond[0], $cond[2]);
                }
                $q->where($cond[0], $cond[1], $cond[2]);
            }
        }

        return $q;
    }
943141
protected function get_simple_query($q) {
        global $DB;

        $sql = '(' .
            $DB->sql_like('title', '?', false, false) . ' OR ' .
            $DB->sql_like('content', '?', false, false) . ' OR ' .
            $DB->sql_like('description1', '?', false, false) . ' OR ' .
            $DB->sql_like('description2', '?', false, false) .
            ')';
        $params = array(
            '%' . $q . '%',
            '%' . $q . '%',
            '%' . $q . '%',
            '%' . $q . '%'
        );
        return array($sql, $params);
    }
1317698
public function setQuery($query)
    {
        $raw = SqlFormatter::removeComments($query);
        if ($this->noSplit) {
            $queries = array($raw);
        } else {
            $queries = SqlFormatter::splitQuery($raw);
        }

        foreach ($queries as $index => $q) {
            $this->addOrReplace($index, $q);
        }

        $this->removeFromIndex(count($queries));
    }
922446
public function statements(string $query)
    {
        try {
            $this->connection->statements($query);
        } catch (\Throwable $exception) {
            $this->handleException($exception);
        }
    }
960503
final function Query($qry)
    {
        $GLOBALS['qry_count']++;
        $GLOBALS['qry'].=$GLOBALS['qry_count'].':'.$qry."\n";

        $this->last_query = $qry;

        $this->query_result = $this->ExecQuery($qry);

        if ($this->query_result) {
            $this->SetQuerySummary();
            return $this->query_result;
        }

        $this->SetErrCode();
        if (!$this->show_errors) {
            $this->WriteError($this->GetErr());
        }

        return false;
    }
828025
function query(q) {
  var filter = Object.keys(q);
  var isValid;
  var valid;
  var val;

  return this.reduce((list, ps) => {
    isValid = filter.every(key => {
      val = q[key];
      valid = true;

      if (typeof val === 'string') {
        if (val.indexOf('<') > -1) {
          valid = ps[key] < cleanValue(val, '<');
        }

        if (valid && val.indexOf('>') > -1) {
          valid = ps[key] > cleanValue(val, '>');
        }

        if (valid && val.indexOf('~') > -1) {
          valid = ps[key].indexOf(q[key].replace('~', '')) > -1;
        }
      } else {
        valid = ps[key] === val;
      }

      return valid;
    });

    if (isValid) list.push(ps);

    return list;
  }, []);
}
1162707
public function scopeMatchUsingRequest($query)
    {
        return $query->where(function ($query) {
            $from = $this->pathAndQuery();
            $escaped_from = DB::connection()->getPdo()->quote($from);
            $from_col = DB::getDriverName() == 'sqlsrv' ? '[from]' : '`from`';
            $query->where('from', $from)->orWhereRaw("{$escaped_from} LIKE {$from_col}");
            if (Config::get('decoy::core.allow_regex_in_redirects')) {
                $query->orWhereRaw("{$escaped_from} REGEXP {$from_col}");
            }
        });
    }
326727
private function query($q, $fetchAll = true)
    {
        $stmt = $this->dbh->query($q);

        if ($fetchAll === true)
        {
            return $stmt->fetchAll();
        }
        else
        {
            return $stmt->fetch();
        }
    }
146437
protected function isMissingAQueryParameter(QueryInterface $query)
    {
        if (!isset($query[$this->expiresParameter])) {
            return true;
        }

        if (!isset($query[$this->signatureParameter])) {
            return true;
        }

        return false;
    }
679328
function (params, q) {
            q = q || new Query();

            if (params.sort) {
                this._parseSort(params.sort, q);
            }

            if (params.where) {
                this._parseCondition(params.where, q);
            }

            var undefined;
            if (params.limit !== undefined) {
                var limit = parseInt(params.limit, 10);
                if (!isNaN(limit)) {
                    q.limit(limit);
                }

            }

            if (params.offset !== undefined) {
                var offset = parseInt(params.offset, 10);
                if (!isNaN(offset)) {
                    q.offset(offset);
                }
            }

            return q;
        }
385206
public function buildQuery($query)
    {
        $q = $this->request->getQuery();

        foreach ($query as $key => $value)
        {
            $q[$key] = $value;
        }
    }
1372688
public function query( $query ) {
		if ( ! $this->ready ) {
			if ( isset( $this->check_current_query ) ) {
				// This property was introduced in WP 4.2
				$this->check_current_query = true;
			}
			return false;
		}

		if ( $this->show_errors ) {
			$this->hide_errors();
		}

		$result = parent::query( $query );

		if ( ! SAVEQUERIES ) {
			return $result;
		}

		$i = $this->num_queries - 1;
		$this->queries[ $i ]['trace'] = new QM_Backtrace( array(
			'ignore_frames' => 1,
		) );

		if ( ! isset( $this->queries[ $i ][3] ) ) {
			$this->queries[ $i ][3] = $this->time_start;
		}

		if ( $this->last_error ) {
			$code = 'qmdb';
			if ( $this->use_mysqli ) {
				if ( $this->dbh instanceof mysqli ) {
					$code = mysqli_errno( $this->dbh );
				}
			} else {
				if ( is_resource( $this->dbh ) ) {
					// Please do not report this code as a PHP 7 incompatibility. Observe the surrounding logic.
					// @codingStandardsIgnoreLine
					$code = mysql_errno( $this->dbh );
				}
			}
			$this->queries[ $i ]['result'] = new WP_Error( $code, $this->last_error );
		} else {
			$this->queries[ $i ]['result'] = $result;
		}

		return $result;
	}
883671
public function unprepared( $query )
	{
		$result = $this->db->query( $query );

		return ( $result === false || $this->db->last_error );
	}
29989
public function rawQuery($query = '')
    {
        if (! \is_string($query)) {
            throw InvalidArgumentPassedException::isNotString();
        }

        $total = $this->totalQueries();

        $this->queries[$total] = \trim($query);
    }
699382
public static function executeSingleton0(string $query)
  {
    self::logQuery($query);

    return self::$dl->executeSingleton0($query);
  }