For queries like http://localhost/NorthWind.svc/Customers
199979
public function getResourceSet(
        QueryType $queryType,
        ResourceSet $resourceSet,
        $filterInfo = null,
        $orderBy = null,
        $top = null,
        $skip = null
    ) {
        $result = new QueryResult();

        $entityClassName = $resourceSet->getResourceType()->getInstanceType()->name;
        $entityName = $this->getEntityName($entityClassName);
        $tableName = $this->getTableName($entityName);

        $option = null;
        if ($queryType == QueryType::ENTITIES_WITH_COUNT()){
            //tell mysql we want to know the count prior to the LIMIT 
            //$option = 'SQL_CALC_FOUND_ROWS';
        }

        $where = $filterInfo ? ' WHERE ' . $filterInfo->getExpressionAsString() : '';

        $order = $orderBy ? ' ORDER BY ' . $this->getOrderByExpressionAsString($orderBy) : '';

        $sqlCount = 'SELECT COUNT(*) FROM ' . $tableName . $where;
        if ($queryType == QueryType::ENTITIES() || $queryType == QueryType::ENTITIES_WITH_COUNT()) {
            $sql = 'SELECT ' . $option . ' * FROM ' . $tableName . $where . $order
                    . ($top ? ' LIMIT ' . $top : '') . ($skip ? ' OFFSET ' . $skip : '');
            $data = $this->queryAll($sql);
            
            if ($queryType == QueryType::ENTITIES_WITH_COUNT()){
                //get those found rows
                //$result->count = $this->queryScalar('SELECT FOUND_ROWS()');
                $result->count = $this->queryScalar($sqlCount);
            }

            $result->results = array_map($entityClassName . '::fromRecord', $data);
        }
        elseif ($queryType == QueryType::COUNT()) {
            $result->count = QueryResult::adjustCountForPaging(
                $this->queryScalar($sqlCount), $top, $skip);
        }

        return $result;
    }
1018319
def target_query(plugin, port, location):
    
    return ((r.row[PLUGIN_NAME_KEY] == plugin) &
            (r.row[PORT_FIELD] == port) &
            (r.row[LOCATION_FIELD] == location))
1316984
def _query_near(*, session=None, **kwargs):
    """"""
    url_endpoint = 'http://calib.org/marine/index.html'
    if session is not None:
        resp = session.get(url_endpoint, params=kwargs)
    else:
        with requests.Session() as s:
            # Need to get the index page before query. Otherwise get bad query response that seems legit.
            s.get('http://calib.org/marine/index.html')
            resp = s.get(url_endpoint, params=kwargs)
    return resp
883048
private function getAllUrlAliasesQuery(): string
    {
        $existingAliasesQueryBuilder = $this->connection->createQueryBuilder();
        $innerQueryBuilder = $this->connection->createQueryBuilder();

        return $existingAliasesQueryBuilder
            ->select('tmp.id')
            ->from(
                // nest subquery to avoid same-table update error
                '(' . $innerQueryBuilder->select('id')->from($this->table)->getSQL() . ')',
                'tmp'
            )
            ->getSQL();
    }
314244
static List<JmxData> query(ObjectName query) throws Exception {
    return query(ManagementFactory.getPlatformMBeanServer(), query);
  }
875694
def marvcli_query(ctx, list_tags, collections, discarded, outdated, path, tags, null):
    
    if not any([collections, discarded, list_tags, outdated, path, tags]):
        click.echo(ctx.get_help())
        ctx.exit(1)

    sep = '\x00' if null else '\n'

    site = create_app().site

    if '*' in collections:
        collections = None
    else:
        for col in collections:
            if col not in site.collections:
                ctx.fail('Unknown collection: {}'.format(col))

    if list_tags:
        tags = site.listtags(collections)
        if tags:
            click.echo(sep.join(tags), nl=not null)
        else:
            click.echo('no tags', err=True)
        return

    setids = site.query(collections, discarded, outdated, path, tags)
    if setids:
        sep = '\x00' if null else '\n'
        click.echo(sep.join(setids), nl=not null)
780927
def query(cls, owner=None, name=None, offset=None, limit=None, api=None):
        
        api = api if api else cls._API
        query_params = {}
        if owner:
            url = cls._URL['query'].format(owner=owner)
        else:
            url = cls._URL['query'].format(owner='')
        if name:
            query_params['name'] = name
        return super(Project, cls)._query(
            url=url, offset=offset, limit=limit, fields='_all',
            api=api, **query_params
        )
130874
function Router_buildQuery(params) {
        var data = [];
        Object.keys(params).forEach(function (key) {
            data.push(key + '=' + encodeURIComponent(params[key]));
        });
        return data.join('&');
    }
850290
public void runQueries() throws Exception {

        System.out.println();
        System.out.println("Running Queries: ");
        System.out.println();

        // Specify, run and print the queries (and their results), one at a time
        runQuery("Select some login sessions - just a small portion of the data (limit results to 10):",
                 "SELECT username, json_data FROM user_session_table ORDER BY username LIMIT 10");
        runQuery("Select some login sessions that have been made to the VoltDB Forum, using 'field' (limit results to 10):",
                 "SELECT username, field(json_data,'site') AS site, json_data FROM user_session_table "
                 + "WHERE field(json_data, 'site')='VoltDB Forum' ORDER BY username LIMIT 10");

        runQuery("Select VoltDB Forum sessions that are moderators (at most 10), using 'field' multiple times:",
                 "SELECT username, field(json_data,'moderator') AS moderator, json_data FROM user_session_table "
                 + "WHERE field(json_data, 'site')='VoltDB Forum' AND field(json_data, 'moderator')='true' ORDER BY username LIMIT 10");
        runQuery("Change user 'voltdb' to be a moderator, using 'set_field':",
                 "UPDATE user_session_table SET json_data = set_field(json_data, 'moderator', 'true') "
                 + "WHERE username='voltdb'");
        runQuery("Select VoltDB Forum sessions that are moderators (again, after update):",
                 "SELECT username, field(json_data,'moderator') AS moderator, json_data FROM user_session_table "
                 + "WHERE field(json_data, 'site')='VoltDB Forum' AND field(json_data, 'moderator')='true' ORDER BY username LIMIT 10");

        runQuery("Select records of (VoltDB Forum) logins with a download_count larger than one:",
                 "SELECT username, field(json_data,'download_count') AS download_count, json_data FROM user_session_table "
                 + "WHERE cast(field(json_data,'download_count') AS INTEGER) > 1 ORDER BY username LIMIT 10");

        runQuery("User pattern matching (SQL LIKE) to look for records of (VoltDB Forum) logins who have downloaded version v2.x "
                 + "- the old way, using nested calls of 'field':",
                 "SELECT username, field(field(json_data,'props'), 'download_version') AS download_version, json_data FROM user_session_table "
                 + "WHERE field(field(json_data,'props'), 'download_version') LIKE 'v2%' ORDER BY username LIMIT 10");
        runQuery("Identical query (logins who have downloaded version v2.x), using newer, simpler dot notation, rather than 'field' twice:",
                 "SELECT username, field(json_data,'props.download_version') AS download_version, json_data FROM user_session_table "
                 + "WHERE field(json_data, 'props.download_version') LIKE 'v2%' ORDER BY username LIMIT 10");
        runQuery("Change several users to set 'props.download_version' to 'v2.9', using 'set_field' with dot notation:",
                 "UPDATE user_session_table SET json_data = set_field(json_data, 'props.download_version', '\"v2.9\"') "
                 + "WHERE username < 'user-10000'");
        runQuery("User pattern matching (SQL LIKE) to look for records of (VoltDB Forum??) logins who have downloaded "
                 + "version v2.x (again, after update):",
                 "SELECT username, field(json_data,'props.download_version') AS download_version, json_data FROM user_session_table "
                 + "WHERE field(json_data, 'props.download_version') LIKE 'v2%' ORDER BY username LIMIT 10");

        runQuery("Select records of (VoltDB Blog) logins whose first role is 'writer' - the old way, using 'array_element':",
                 "SELECT username, array_element(field(json_data,'roles'), 0) AS first_role, json_data FROM user_session_table "
                 + "WHERE array_element(field(json_data,'roles'), 0)='writer' ORDER BY username LIMIT 10");
        runQuery("Identical query (logins whose first role is 'writer'), using newer, simpler bracket notation, "
                 + "rather than 'array_element':",
                 "SELECT username, field(json_data,'roles[0]') AS first_role, json_data FROM user_session_table "
                 + "WHERE field(json_data,'roles[0]')='writer' ORDER BY username LIMIT 10");

        runQuery("Select records of (VoltDB Blog) logins that have more than one role, using 'array_length':",
                 "SELECT username, field(json_data,'roles[0]') AS first_role, field(json_data,'roles[1]') AS second_role, "
                 + "field(json_data,'roles[2]') AS third_role, json_data FROM user_session_table "
                 + "WHERE array_length(field(json_data,'roles')) > 1 ORDER BY username LIMIT 10");
        runQuery("Change user voltdb2's first role to be 'author' (to match the others), using 'set_field' with bracket notation:",
                 "UPDATE user_session_table SET json_data = set_field(json_data, 'roles[0]', '\"author\"') "
                 + "WHERE username='voltdb2'");
        runQuery("Add an additional role to user 'voltdb2': 'administrator', using 'set_field' with [-1] to mean beyond the last:",
                 "UPDATE user_session_table SET json_data = set_field(json_data, 'roles[-1]', '\"administrator\"') "
                 + "WHERE username='voltdb2'");
        runQuery("Select records of (VoltDB Blog) logins that have more than one role (again, after updates):",
                 "SELECT username, field(json_data,'roles[0]') AS first_role, field(json_data,'roles[1]') AS second_role, "
                 + "field(json_data,'roles[2]') AS third_role, json_data FROM user_session_table "
                 + "WHERE array_length(field(json_data,'roles')) > 1 ORDER BY username LIMIT 10");

        runQuery("Select records of (VoltDB Blog) logins whose last role is 'administrator', using 'field' with [-1] to mean the last:",
                 "SELECT username, field(json_data,'roles[-1]') AS last_role, json_data FROM user_session_table "
                 + "WHERE field(json_data,'roles[-1]')='administrator' ORDER BY username LIMIT 10");

        runQuery("Look deep into the JSON data for records of (VoltDB Forum) logins who have downloaded version v3.0 and "
                 + "have specified a (first) client language of Java (combines dot and bracket notation):",
                 "SELECT username, json_data FROM user_session_table "
                 + "WHERE field(json_data, 'props.download_version')='v3.0' and field(json_data, 'props.client_languages[0]')='Java' "
                 + "ORDER BY username LIMIT 10");

        runQuery("Select records of (VoltDB Forum) logins that have more than one client language (combines "
                 + "'array_length' and 'field' with dot notation):",
                 "SELECT username, field(json_data,'props.client_languages') AS client_languages, json_data FROM user_session_table "
                 + "WHERE array_length(field(json_data,'props.client_languages')) > 1 ORDER BY username LIMIT 10");

        runQuery("Select records of (VoltDB Forum) logins whose second client language is Java:",
                 "SELECT username, field(json_data,'props.client_languages') AS client_languages, json_data FROM user_session_table "
                 + "WHERE field(json_data,'props.client_languages[1]')='Java' ORDER BY username LIMIT 10");
        runQuery("Change user voltdb's second client language to be 'Java' (to match):",
                 "UPDATE user_session_table SET json_data = set_field(json_data, 'props.client_languages[1]', '\"Java\"') "
                 + "WHERE username='voltdb'");
        runQuery("Change user voltdb's third client language to be 'Ruby':",
                 "UPDATE user_session_table SET json_data = set_field(json_data, 'props.client_languages[2]', '\"Ruby\"') "
                 + "WHERE username='voltdb'");
        runQuery("Select records of (VoltDB Forum) logins whose second client language is Java (again, after updates):",
                 "SELECT username, field(json_data,'props.client_languages') AS client_languages, json_data FROM user_session_table "
                 + "WHERE field(json_data,'props.client_languages[1]')='Java' ORDER BY username LIMIT 10");
        runQuery("Add an additional client language to user 'voltdb': 'Python' (using 'set_field', combines dot and "
                 + "bracket notation, with [-1]):",
                 "UPDATE user_session_table SET json_data = set_field(json_data, 'props.client_languages[-1]', '\"Python\"') "
                 + "WHERE username='voltdb'");
        runQuery("Select records of (VoltDB Forum) logins whose second client language is Java (again, after one more update):",
                 "SELECT username, field(json_data,'props.client_languages') AS client_languages, json_data FROM user_session_table "
                 + "WHERE field(json_data,'props.client_languages[1]')='Java' ORDER BY username LIMIT 10");

        runQuery("Select records of (VoltDB Blog) logins whose last client language is 'Python' (using 'field', combines "
                 + "dot and bracket notation, with [-1]):",
                 "SELECT username, field(json_data,'props.client_languages') AS client_languages, json_data FROM user_session_table "
                 + "WHERE field(json_data,'props.client_languages[-1]')='Python' ORDER BY username LIMIT 10");

        // Display the whole query results as a JSON String
        String SQL = "SELECT json_data FROM user_session_table WHERE username='voltdb' OR username='voltdb2' ORDER BY username";
        VoltTable table = runQuery("Retrieve the JSON data for two particular logins. Treat the whole result set as JSON:", SQL);
        System.out.println("The whole result set as JSON:");
        System.out.println(table.toJSONString());
        System.out.println();

        // Display individual results as JSON
        table = runQuery("Retrieve the JSON data for two particular logins. Just grab a JSON value from the result:", SQL);
        table.advanceRow();
        System.out.println("JSON value from result's first tuple:");
        System.out.println(table.get("json_data", VoltType.STRING));
        System.out.println();
        table.advanceRow();
        System.out.println("JSON value from result's second tuple:");
        System.out.println(table.get("json_data", VoltType.STRING));
        System.out.println();
    }
905974
function query(queryString, args, callback) {
  getClient(function (err, client) {
    if (err) { callback(err); }

    if (!client) {
      callback('Could not connect to the database');
    }
    else {
      runQuery(client, queryString, args, callback);
    }
  });
}
435828
def query(qname, rdtype=dns.rdatatype.A, rdclass=dns.rdataclass.IN,
          tcp=False, source=None, raise_on_no_answer=True, resolver=None):
    """"""
    if resolver is None:
        resolver = get_default_resolver()
    return resolver.query(qname, rdtype, rdclass, tcp, source, raise_on_no_answer)
1291068
def query(self):
        """"""
        if self._query is None:
            query_string = self.environ.get('QUERY_STRING')
            self._query = QueryDict([
                (k.decode('utf-8'), v.decode('utf-8'))
                for k, v in urlparse.parse_qsl(
                    query_string, keep_blank_values=True)
            ])
        return self._query
324626
function buildQuery(opts, globalSearch) {
    var imboQuery = new ImboQuery();

    imboQuery.page(opts.page);
    imboQuery.limit(opts.limit);

    if (opts.users && globalSearch) {
        imboQuery.users(opts.users);
    }

    if (opts.fields) {
        imboQuery.fields(opts.fields);
    }

    if (opts.sort) {
        imboQuery.addSorts(opts.sort);
    }

    if (opts.metadata) {
        imboQuery.metadata(opts.metadata);
    }

    return imboQuery;
}
71218
function buildQueryString(params) {
    var querystring = '';
    for(param in params) {
        querystring += '&' + param + '=' + params[param];
    }
    return querystring;
}
1244909
def query(query_str)
      # puts "conent #{content}"
      res = conn.post '/query/', {query: query_str, time: Time.now.to_i}.to_json do |req|
        req.headers['Content-Type'] = 'application/json'
        req.headers['X-Requested-With'] = 'XMLHttpRequest'
        req['Cookie'] = "csrftoken=#{csrf_token}"
        req.headers['X-CSRFToken'] = csrf_token
      end
      JSON.parse(res.body)
   end
728931
def query(method='GET', profile_dict=None, url=None, path='api/v1',
          action=None, api_key=None, service=None, params=None,
          data=None, subdomain=None, client_url=None, description=None,
          opts=None, verify_ssl=True):
    '''
    
    '''
    user_agent = 'SaltStack {0}'.format(__version__)

    if opts is None:
        opts = {}

    if isinstance(profile_dict, dict):
        creds = profile_dict
    else:
        creds = {}

    if api_key is not None:
        creds['pagerduty.api_key'] = api_key

    if service is not None:
        creds['pagerduty.service'] = service

    if subdomain is not None:
        creds['pagerduty.subdomain'] = subdomain

    if client_url is None:
        client_url = 'https://{0}.pagerduty.com'.format(
            creds['pagerduty.subdomain']
        )

    if url is None:
        url = 'https://{0}.pagerduty.com/{1}/{2}'.format(
            creds['pagerduty.subdomain'],
            path,
            action
        )

    if params is None:
        params = {}

    if data is None:
        data = {}

    data['client'] = user_agent

    # pagerduty.service is not documented.  While it makes sense to have in
    # some cases, don't force it when it is not defined.
    if 'pagerduty.service' in creds and creds['pagerduty.service'] is not None:
        data['service_key'] = creds['pagerduty.service']
    data['client_url'] = client_url
    if 'event_type' not in data:
        data['event_type'] = 'trigger'
    if 'description' not in data:
        if not description:
            data['description'] = 'SaltStack Event Triggered'
        else:
            data['description'] = description

    headers = {
        'User-Agent': user_agent,
        'Authorization': 'Token token={0}'.format(creds['pagerduty.api_key'])
    }
    if method == 'GET':
        data = {}
    else:
        headers['Content-type'] = 'application/json'

    result = salt.utils.http.query(
        url,
        method,
        params=params,
        header_dict=headers,
        data=salt.utils.json.dumps(data),
        decode=False,
        text=True,
        opts=opts,
    )

    return result['text']
1303170
function QueryWhere(data)
{
	//Initialize the string
	var sql = '';

	//Check the type
	if(typeof data === 'string')
	{
		//Return the where
		return data;
	}

	//Get all data
	for(var key in data)
	{
		//Save data value
		var value = data[key];

		//Check the data type
		if(typeof value === 'string' || value instanceof String)
		{
			//Add the quotes
			value = '"' + value + '"';
		}

		//Check if is necessary add the AND
		if(sql !== '')
		{
			//Add the AND
			sql = sql + ' AND ';
		}

		//Add the key=value
		sql = sql + key + '=' + value;
	}

	//Return the string
	return sql;
}