3 namespace Wikimedia\Rdbms
;
6 * Raw SQL value to be used in query builders
8 * @note This should be used very rarely and NEVER with user input.
14 private string $value = '';
17 * This should be used very rarely and NEVER with user input.
19 * Most common usecases is the value in a SET clause of UPDATE,
20 * e.g. for updates like `total_pages = total_pages + 1`:
22 * $queryBuilder->set( [ 'total_pages' => new RawSQLValue( 'total_pages + 1' ) ] )
24 * …or as one side of a comparison in a WHERE condition,
25 * e.g. for conditions like `range_start = range_end`, `range_start != range_end`:
27 * $queryBuilder->where( [ 'range_start' => new RawSQLValue( 'range_end' ) ] )
28 * $queryBuilder->where( $db->expr( 'range_start', '!=', new RawSQLValue( 'range_end' ) ) )
30 * (When all values are literals, consider whether using RawSQLExpression is more readable.)
32 * @param string $value Value (SQL fragment)
33 * @param-taint $value exec_sql
36 public function __construct( string $value ) {
37 $this->value
= $value;
41 * @internal to be used by rdbms library only
43 public function toSql(): string {