class CRM_Utils_Type

Constants

T_INT

T_STRING

T_ENUM

T_DATE

T_TIME

T_BOOLEAN

T_TEXT

T_LONGTEXT

T_BLOB

T_TIMESTAMP

T_FLOAT

T_MONEY

T_EMAIL

T_URL

T_CCNUM

T_MEDIUMBLOB

TWO

FOUR

SIX

EIGHT

TWELVE

SIXTEEN

TWENTY

MEDIUM

THIRTY

BIG

FORTYFIVE

HUGE

BLOB_SIZE

Maximum size of a MySQL BLOB or TEXT column in bytes.

INT_MAX

Maximum value of a MySQL signed INT column.

Methods

static string
typeToString(int $type)

Gets the string representation for a data type.

static array
getValidTypes()

No description

static string
getDataTypeFromFieldMetadata(array $fieldMetadata)

Get the data_type for the field.

static 
escapeAll($data, $type, $abort = TRUE)

Helper function to call escape on arrays.

static 
validateAll($data, $type, $abort = TRUE)

Helper function to call validate on arrays

static mixed
escape(mixed $data, string $type, bool $abort = TRUE)

Verify that a variable is of a given type, and apply a bit of processing.

static mixed
validate(mixed $data, string $type, bool $abort = TRUE, string $name = 'One of parameters ', bool $isThrowException = TRUE)

Verify that a variable is of a given type.

static string
mysqlOrderByFieldFunctionCallback(string $clause)

Preg_replace_callback for mysqlOrderByFieldFunction escape.

static 
mysqlOrderByCallback($matches)

preg_replace_callback for MysqlOrderBy escape.

static array
dataTypes()

Get list of avaliable Data Types for Option Groups

Details

at line 89
static string typeToString(int $type)

Gets the string representation for a data type.

Parameters

int $type Integer number identifying the data type.

Return Value

string String identifying the data type, e.g. 'Int' or 'String'.

at line 160
static array getValidTypes()

Return Value

array An array of type in the form 'type name' => 'int representing type'

at line 186
static string getDataTypeFromFieldMetadata(array $fieldMetadata)

Get the data_type for the field.

Parameters

array $fieldMetadata Metadata about the field.

Return Value

string

at line 205
static escapeAll($data, $type, $abort = TRUE)

Helper function to call escape on arrays.

Parameters

$data
$type
$abort

See also

escape

at line 217
static validateAll($data, $type, $abort = TRUE)

Helper function to call validate on arrays

Parameters

$data
$type
$abort

See also

validate

at line 238
static mixed escape(mixed $data, string $type, bool $abort = TRUE)

Verify that a variable is of a given type, and apply a bit of processing.

Parameters

mixed $data The value to be verified/escaped.
string $type The type to verify against.
bool $abort If TRUE, the operation will CRM_Core_Error::fatal() on invalid data.

Return Value

mixed The data, escaped if necessary.

Exceptions

CRM_Core_Exception

at line 379
static mixed validate(mixed $data, string $type, bool $abort = TRUE, string $name = 'One of parameters ', bool $isThrowException = TRUE)

Verify that a variable is of a given type.

Parameters

mixed $data The value to validate.
string $type The type to validate against.
bool $abort If TRUE, the operation will CRM_Core_Error::fatal() on invalid data.
string $name The name of the attribute
bool $isThrowException Should an exception be thrown rather than a using a deprecated fatal error.

Return Value

mixed The data, escaped if necessary

Exceptions

CRM_Core_Exception

at line 503
static string mysqlOrderByFieldFunctionCallback(string $clause)

Preg_replace_callback for mysqlOrderByFieldFunction escape.

Add backticks around the field name.

Parameters

string $clause

Return Value

string

at line 510
static mysqlOrderByCallback($matches)

preg_replace_callback for MysqlOrderBy escape.

Parameters

$matches

at line 537
static array dataTypes()

Get list of avaliable Data Types for Option Groups

Return Value

array