MediaWiki master
Wikimedia\Rdbms\RawSQLExpression Class Reference

Raw SQL expression to be used in query builders. More...

Inherits Wikimedia\Rdbms\Expression.

Collaboration diagram for Wikimedia\Rdbms\RawSQLExpression:

Public Member Functions

 __construct (string $expression)
 This should be used very rarely and NEVER with user input.
 
 toGeneralizedSql ()
 
 toSql (DbQuoter $dbQuoter)
 
- Public Member Functions inherited from Wikimedia\Rdbms\Expression
 __construct (string $field, string $op, $value)
 Store an expression.
 
 and (string $field, string $op, $value)
 
 andExpr (IExpression $expr)
 
 or (string $field, string $op, $value)
 
 orExpr (IExpression $expr)
 

Additional Inherited Members

- Public Attributes inherited from Wikimedia\Rdbms\IExpression
const ACCEPTABLE_OPERATORS = [ '>', '<', '!=', '=', '>=', '<=', self::LIKE, self::NOT_LIKE ]
 
const LIKE = 'LIKE'
 
const NOT_LIKE = 'NOT LIKE'
 

Detailed Description

Raw SQL expression to be used in query builders.

Note
This should be used very rarely and NEVER with user input.
Stability: newable
Since
1.42

Definition at line 15 of file RawSQLExpression.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Rdbms\RawSQLExpression::__construct ( string $expression)

This should be used very rarely and NEVER with user input.

It can be used as a boolean expression in a WHERE condition, in cases where $db->expr() can't be used because the expression doesn't have a left side, operator and right side, e.g. for conditions like WHERE EXISTS( SELECT ... ).

$queryBuilder->where( new RawSQLExpression( 'EXISTS(' . $subqueryBuilder->getSQL() . ')' ) )

Or when the condition is a simple SQL literal and writing it as SQL is the easiest:

$queryBuilder->where( new RawSQLExpression( 'range_start != range_end' ) )

(See also RawSQLValue, which may be more readable in other cases.)

Parameters
string$expressionExpression (SQL fragment)
Since
1.42

Definition at line 37 of file RawSQLExpression.php.

Member Function Documentation

◆ toGeneralizedSql()

Wikimedia\Rdbms\RawSQLExpression::toGeneralizedSql ( )
Access: internal
to be used by rdbms library only

Reimplemented from Wikimedia\Rdbms\Expression.

Definition at line 48 of file RawSQLExpression.php.

◆ toSql()

Wikimedia\Rdbms\RawSQLExpression::toSql ( DbQuoter $dbQuoter)
Access: internal
to be used by rdbms library only

Reimplemented from Wikimedia\Rdbms\Expression.

Definition at line 44 of file RawSQLExpression.php.


The documentation for this class was generated from the following file: