QBFunctions
Last updated
Was this helpful?
Last updated
Was this helpful?
The QBFunctions
class provides a comprehensive set of SQL functions designed to enhance query building in QBSelect
. It enables the creation of mathematical, string, and date-based expressions, along with conditional and custom logic.
This class allows users to perform operations like calculating absolute values, rounding, and extracting substrings. It also includes advanced capabilities such as casting data types, concatenating strings, trimming whitespace, and formatting dates. With access to aggregation methods and support for custom function definitions, the class is versatile in handling diverse SQL requirements.
For additional guidance on query construction and execution, refer to the section of the documentation.
Get query builder parent table clause, this may be a query or a join clause.
Get query builder parent.
Create abs(column) expression
Create bit_length(column) expression
Cast using type name.
Create ceil(column) expression
Create concat(args, arg2) expression
Create day(date) expression
Create divide(args, arg2) expression
Create floor(column) expression
Create hour(date) expression
Create length(column) expression
Create locate(str1, str2) expression
Create locate(str1, str2, start) expression
Create lower(column) expression
Create minus(args, arg2) expression
Create minute(date) expression
Create mod(dividend, divisor) expression
Create month(date) expression
Create multiply(args, arg2) expression
Create nullif(arg1, arg2) expression
Create plus(args, arg2) expression
Create round(column) expression
Create round(column) expression
Create second(date) expression
Create sqrt(column) expression
Create substring(column, pos) expression
Create substring(column, pos, len) expression
Create trim(column) expression
Create trim([leading | trailing | both] [characters] from column)
Create upper(column) expression
Create year(date) expression
Get query builder parent table clause, this may be a query or a join clause.
Sample
Get query builder parent.
Sample
Create abs(column) expression
Parameters
Sample
Create bit_length(column) expression
Parameters
Sample
Cast using type name.
Parameters
Sample
Create ceil(column) expression
Parameters
Sample
Parameters
Sample
Create concat(args, arg2) expression
Parameters
Sample
Parameters
Sample
Create day(date) expression
Parameters
Sample
Create divide(args, arg2) expression
Parameters
Sample
Create floor(column) expression
Parameters
Sample
Create hour(date) expression
Parameters
Sample
Create length(column) expression
Parameters
Sample
Create locate(str1, str2) expression
Parameters
Sample
Create locate(str1, str2, start) expression
Parameters
Sample
Create lower(column) expression
Parameters
Sample
Create minus(args, arg2) expression
Parameters
Sample
Create minute(date) expression
Parameters
Sample
Create mod(dividend, divisor) expression
Parameters
Sample
Create month(date) expression
Parameters
Sample
Create multiply(args, arg2) expression
Parameters
Sample
Create nullif(arg1, arg2) expression
Parameters
Sample
Create plus(args, arg2) expression
Parameters
Sample
Create round(column) expression
Parameters
Sample
Create round(column) expression
Parameters
Sample
Create second(date) expression
Parameters
Sample
Create sqrt(column) expression
Parameters
Sample
Create substring(column, pos) expression
Parameters
Sample
Create substring(column, pos, len) expression
Parameters
Sample
Create trim(column) expression
Parameters
Sample
Create trim([leading | trailing | both] [characters] from column)
Parameters
Sample
Create upper(column) expression
Parameters
Sample
Create year(date) expression
Parameters
Sample
Type
Type
value ;
Returns: A query builder function representing the absolute value of the input.
value ;
Returns: A query builder function representing the bit length of the value.
value object to cast
type type see QUERY_COLUMN_TYPES
Returns: A query builder function representing the value cast to the specified type.
arg number object
Returns: A query builder function representing the smallest integer greater than or equal to the input.
args arguments to coalesce
Returns: A query builder function that returns the first non-null argument.
arg1 ;
arg2 ;
Returns: A query builder function representing the concatenation of two arguments.
name custom function name
args function arguments
Returns: A query builder function representing a custom function with the given name and arguments.
arg date object
Returns: A query builder function representing the day component of a date/time value.
arg1 ;
arg2 ;
Returns: A query builder function representing the division of two arguments.
arg number object
Returns: A query builder function representing the largest integer less than or equal to the input.
arg date object
Returns: A query builder function representing the hour component of a date/time value.
value ;
Returns: A query builder function representing the length of the value.
string1 string to locate
string2 string to search in
Returns: A query builder function representing the position of the first occurrence of one string in another.
string1 string to locate
string2 string to search in
start start pos
Returns: A query builder function representing the position of the first occurrence of one string in another, starting from a given position.
value ;
Returns: A query builder function representing the value converted to lowercase.
arg1 ;
arg2 ;
Returns: A query builder function representing the difference between two arguments.
arg date object
Returns: A query builder function representing the minute component of a date/time value.
dividend ;
divisor ;
Returns: A query builder function representing the remainder of the division of two numbers.
arg date object
Returns: A query builder function representing the month component of a date/time value.
arg1 ;
arg2 ;
Returns: A query builder function representing the product of two arguments.
arg1 ;
Returns: A query builder function that returns null if the two arguments are equal.
arg1 ;
arg2 ;
Returns: A query builder function representing the sum of two arguments.
arg number object
Returns: A query builder function representing the input rounded to the nearest integer.
arg number object
decimals The number of decimal places to round number to, default 0
Returns: A query builder function representing the input rounded to the specified number of decimal places.
arg date object
Returns: A query builder function representing the second component of a date/time value.
value ;
Returns: A query builder function representing the square root of the input.
arg column name
pos position
Returns: A query builder function representing a substring starting at the specified position.
arg column name
pos position
len length
Returns: A query builder function representing a substring of specified length starting at the specified position.
value ;
Returns: A query builder function representing the value with leading and trailing spaces removed.
leading_trailing_both 'leading', 'trailing' or 'both'
characters characters to remove
fromKeyword 'from'
value value to trim
Returns: A query builder function representing the value with specified characters trimmed from a specified position.
value ;
Returns: A query builder function representing the value converted to uppercase.
arg date object
Returns: A query builder function representing the year component of a date/time value.