phpBB

Development Wiki

Dbal.sql in set

From phpBB Development Wiki

dbal::sql_in_set –– Builds in set string for use within an sql_query.

This article is a stub. You can help in improving Olympus Documentation by expanding it.

Description

  1. string sql_in_set ( String $column , Array $array [, Bool $negate [, Bool $allow_empty_set ]] )

Builds IN, NOT IN, = and <> sql comparison string. Defined in dbal class. The array of parameters and values is processed through the _sql_validate_value function which takes care of proper casting and escaping which means there is no need to use sql_escape for the various elements of the array.

Parameters

Parameter Usage
column Name of the sql column that shall be compared.
array Array of values that are allowed (IN) or not allowed (NOT IN).
negate (Optional) true for NOT IN (), false for IN () (default).
allow_empty_set (Optional) If true, allow $array to be empty, this function will return 1=1 or 1=0 then. Default to false.

Return Values

Returns a string to be used in the WHERE clause of an SQL Query

Examples

Example #1

$sql_in = array(25862);

$sql 'SELECT *
    FROM ' 
USERS_TABLE '
    WHERE ' 
$db->sql_in_set('user_id'$sql_in);


See Also