function date_sql_pad in Date 7.2
Same name and namespace in other branches
- 8 date_api/date_api.module \date_sql_pad()
- 5 date.inc \date_sql_pad()
- 6.2 date_api_sql.inc \date_sql_pad()
- 6 date_api_sql.inc \date_sql_pad()
- 7.3 date_api/date_api_sql.inc \date_sql_pad()
- 7 date_api/date_api_sql.inc \date_sql_pad()
A helper function to do cross-database padding of date parts.
Parameters
string $str: A string to apply padding to.
int $size: The size the final string should be.
string $pad: The value to pad the string with.
string $side: The side of the string to pad.
File
- date_api/
date_api_sql.inc, line 61 - SQL helper for Date API.
Code
function date_sql_pad($str, $size = 2, $pad = '0', $side = 'l') {
switch ($side) {
case 'r':
return "RPAD({$str}, {$size}, '{$pad}')";
default:
return "LPAD({$str}, {$size}, '{$pad}')";
}
}