當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TimeDate::toDatabaseTime方法代碼示例

本文整理匯總了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;
    }
}
開發者ID:joomux,項目名稱:jTips,代碼行數:87,代碼來源:functions.inc.php


注:本文中的TimeDate::toDatabaseTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。