BEWARE:
$sql = 'SELECT whatever FROM wherever WHERE 1=1';
i did that once with a DELETE-statement which got its where arguments by
request-parameters
like this:
$sql = 'DELETE FROM wherever WHERE 1=1';
if ( isset ( $_REQUEST[ 'fid' ] )
{
$sql .= " AND fid='".$_REQUEST[ 'fid' ]."';
execute_sql( $sql );
}
if ( isset ( $_REQUEST[ 'aid' ] )
{
$sql .= " AND fid='".$_REQUEST[ 'aid' ]."';
execute_sql( $sql );
}
if ( isset ( $_REQUEST[ 'bid' ] )
{
$sql .= " AND fid='".$_REQUEST[ 'bid' ]."';
execute_sql( $sql );
}
got the admins running with tapes 3 times that day 🙂
( the parameter was named "fuid" )
maybe thomething like this:
$sql = array();
if ( isset ( $_REQUEST[ 'fid' ] )
{
$sql[] = "fid='".$_REQUEST[ 'fid' ]."';
}
$statement = implode( ' AND ', $sql );
if ( is_ok( $statement ) )
{
execute_sql( 'SELECT whatever FROM wherever WHERE '. $statement );
}
with that you can spare the WHERE 1=1