Function DatabaseDriver->db_function
Definitions
sources/database.php
- Call a database function that may be different on different database drivers.We are using MySQL syntax as a de facto standard. SQL does not standardise this stuff well.Basic arithmetic and inequality operators are assumed supported without needing a function.Note that AVG may return an integer or float, depending on whether the DB engine auto-converts round numbers to integers. MySQL seems to.Note that we are hard-coding for different database drivers in here, as it is easier to maintain the code and reference possibilities in one place.Database drivers can still override this whole method if they need to.Remember to add a test to the database_misc.php test.
- Visibility: public
- Is abstract?: No
- Is static?: No
- Is final?: No
- Returns: string
Parameters
Name | Type | Passed by reference? | Variadic? | Default | Set | Range | Description |
---|---|---|---|---|---|---|---|
$function | string | No | No | required parameter | IFF CONCAT UPPER LOWER REPLACE SUBSTR INSTR LENGTH RAND COALESCE LEAST GREATEST MOD ABS MD5 REVERSE GROUP_CONCAT X_ORDER_BY_BOOLEAN | N/A | Function name |
$args | array | No | No | [] | N/A | N/A | List of string arguments, assumed already quoted/escaped correctly for the particular database |
Returns
- SQL fragment (null: not supported)
- Type: ?string
- Set: N/A
- Range: N/A
Preview
Code (PHP)
/**
* Call a database function that may be different on different database drivers.We are using MySQL syntax as a de facto standard. SQL does not standardise this stuff well.Basic arithmetic and inequality operators are assumed supported without needing a function.Note that AVG may return an integer or float, depending on whether the DB engine auto-converts round numbers to integers. MySQL seems to.Note that we are hard-coding for different database drivers in here, as it is easier to maintain the code and reference possibilities in one place.Database drivers can still override this whole method if they need to.Remember to add a test to the database_misc.php test.
*
* @param string $function Function name
* @set IFF CONCAT UPPER LOWER REPLACE SUBSTR INSTR LENGTH RAND COALESCE LEAST GREATEST MOD ABS MD5 REVERSE GROUP_CONCAT X_ORDER_BY_BOOLEAN
* @param array $args List of string arguments, assumed already quoted/escaped correctly for the particular database
* @return ?string SQL fragment (null: not supported)
*/
public function db_function(string $function, array $args = []) : ?string
* Call a database function that may be different on different database drivers.We are using MySQL syntax as a de facto standard. SQL does not standardise this stuff well.Basic arithmetic and inequality operators are assumed supported without needing a function.Note that AVG may return an integer or float, depending on whether the DB engine auto-converts round numbers to integers. MySQL seems to.Note that we are hard-coding for different database drivers in here, as it is easier to maintain the code and reference possibilities in one place.Database drivers can still override this whole method if they need to.Remember to add a test to the database_misc.php test.
*
* @param string $function Function name
* @set IFF CONCAT UPPER LOWER REPLACE SUBSTR INSTR LENGTH RAND COALESCE LEAST GREATEST MOD ABS MD5 REVERSE GROUP_CONCAT X_ORDER_BY_BOOLEAN
* @param array $args List of string arguments, assumed already quoted/escaped correctly for the particular database
* @return ?string SQL fragment (null: not supported)
*/
public function db_function(string $function, array $args = []) : ?string