本文整理汇总了PHP中TimeDate::toDatabaseTime方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeDate::toDatabaseTime方法的具体用法?PHP TimeDate::toDatabaseTime怎么用?PHP TimeDate::toDatabaseTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeDate
的用法示例。
在下文中一共展示了TimeDate::toDatabaseTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseDataType
function parseDataType(&$data, $column, $field)
{
global $database;
$dataval = $data[$column];
switch ($field['type']) {
case 'int':
if (is_numeric($dataval)) {
return $dataval;
} else {
return 0;
}
break;
case 'double':
case 'float':
if (is_float($dataval)) {
return $dataval;
} else {
return 0;
}
break;
case 'bool':
if ($dataval == 1 or preg_match('/yes/i', $dataval)) {
return 1;
} else {
return 0;
}
break;
case 'date':
//return toDbDate($dataval);
return TimeDate::toDatabaseDate($dataval);
break;
case 'datetime':
//return toDbDateTime($dataval);
return TimeDate::toDatabaseDateTime($dataval);
break;
case 'time':
//return toDbTime($dataval);
return TimeDate::toDatabaseTime($dataval);
break;
case 'relate':
//Locate an existing record matching the given data value
//If nothing found create a skeleton record with the supplied data
//Return key of supplied data in related table.
$class = $field['related'];
$obj = new $class($database);
$related_fields = $field['related_fields'];
if (count($related_fields) > 1) {
$values = preg_split('/[\\s]+/', $dataval);
} else {
$values = array($dataval);
}
$max = min(count($values), count($related_fields));
$params = array();
for ($i = 0; $i < $max; $i++) {
$params[$related_fields[$i]] = $values[$i];
}
if (isset($field['dependency']) and !empty($field['dependency'])) {
$params[$field['dependency']['key']] = getDependentField($field, $data, $_POST['importFields']);
}
//jTipsDebug($_POST);
//jTipsDebug($dataval);
//jTipsDebug($field);
//jTipsDebug($params);
//die();
$obj->loadByParams($params);
$rel_key = $field['related_key'];
if (isset($obj->{$rel_key}) and !empty($rel_key)) {
return $obj->{$rel_key};
} else {
if ($field['required']) {
$obj->bind($params);
$obj->save();
return $obj->{$rel_key};
} else {
return $field['default'];
}
}
break;
case 'virtual':
continue;
break;
case 'text':
default:
return mysql_real_escape_string($dataval);
break;
}
}