public function StringArgument::getFormula in Drupal 8
Same name and namespace in other branches
- 9 core/modules/views/src/Plugin/views/argument/StringArgument.php \Drupal\views\Plugin\views\argument\StringArgument::getFormula()
Get the formula for this argument.
$this->ensureMyTable() MUST have been called prior to this.
2 calls to StringArgument::getFormula()
- StringArgument::query in core/
modules/ views/ src/ Plugin/ views/ argument/ StringArgument.php - Build the query based upon the formula
- StringArgument::summaryQuery in core/
modules/ views/ src/ Plugin/ views/ argument/ StringArgument.php - Build the summary query based on a string
File
- core/
modules/ views/ src/ Plugin/ views/ argument/ StringArgument.php, line 175
Class
- StringArgument
- Basic argument handler to implement string arguments that may have length limits.
Namespace
Drupal\views\Plugin\views\argumentCode
public function getFormula() {
$formula = "SUBSTRING({$this->tableAlias}.{$this->realField}, 1, " . intval($this->options['limit']) . ")";
if ($this->options['case'] != 'none') {
// Support case-insensitive substring comparisons for SQLite by using the
// 'NOCASE_UTF8' collation.
// @see Drupal\Core\Database\Driver\sqlite\Connection::open()
if (Database::getConnection()
->databaseType() == 'sqlite') {
$formula .= ' COLLATE NOCASE_UTF8';
}
// Support case-insensitive substring comparisons for PostgreSQL by
// converting the formula to lowercase.
if (Database::getConnection()
->databaseType() == 'pgsql') {
$formula = 'LOWER(' . $formula . ')';
}
}
return $formula;
}