Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

sql_null_or_val()

Description

Query helper function for insert/update statements to avoid repetitive checks when value might be NULL or an actual value.
Helps keeping database level data as expected (ie. uses an actual NULL value when there's no data as opposed to empty strings)

Parameters

ColumnTypeDefaultDescription
$v string Non-null value
$cond boolean Condition to set it to NULL or to use the escaped value

Return

string

This article was last updated 1st July 2022 10:35 Europe/London time based on the source file dated 1st July 2022 10:15 Europe/London time.