MediaWiki master
Wikimedia\Rdbms\RawSQLValue Class Reference

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

Public Member Functions

 __construct (string $value)
 This should be used very rarely and NEVER with user input.
 
 toSql ()
 

Detailed Description

Raw SQL value to be used in query builders.

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

Definition at line 13 of file RawSQLValue.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Rdbms\RawSQLValue::__construct ( string $value)

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

Most common usecases is the value in a SET clause of UPDATE, e.g. for updates like total_pages = total_pages + 1:

$queryBuilder->set( [ 'total_pages' => new RawSQLValue( 'total_pages + 1' ) ] )

…or as one side of a comparison in a WHERE condition, e.g. for conditions like range_start = range_end, range_start != range_end:

$queryBuilder->where( [ 'range_start' => new RawSQLValue( 'range_end' ) ] ) $queryBuilder->where( $db->expr( 'range_start', '!=', new RawSQLValue( 'range_end' ) ) )

(When all values are literals, consider whether using RawSQLExpression is more readable.)

Parameters
string$valueValue (SQL fragment)
Since
1.43

Definition at line 36 of file RawSQLValue.php.

Member Function Documentation

◆ toSql()

Wikimedia\Rdbms\RawSQLValue::toSql ( )
Access: internal
to be used by rdbms library only

Definition at line 43 of file RawSQLValue.php.


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