Skip to main content

TimeSqlMapper

Formats an n2n\util\calendar\Time value into a SQL time string (via Time::toSql()), or leaves null untouched. It performs no validation.

Accepts the following input types:

  • n2n\util\calendar\Time — formatted via Time::toSql().
  • null — left as null.

A value that is not a Time (e.g. a \DateTime or a string) throws BindMismatchException. Use Mappers::time() first if you need to parse strings.

Example: formatting to a SQL time string​

$result = Bind::values(new Time('10:11:12'), null)
->map(Mappers::timeSql())->toArray()->exec();
var_dump($result->get());

Output:

array(2) {
[0]=>
string(8) "10:11:12"
[1]=>
NULL
}