function date_sql_pad in Date 7
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.2 date_api/date_api_sql.inc \date_sql_pad()
A helper function to do cross-database padding of date parts
Parameters
$str - a string to apply padding to: @param $size - the size the final string should be @param $pad - the value to pad the string with @param $side - the side of the string to pad
File
- date_api/
date_api_sql.inc, line 51 - 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}')";
}
}