当前位置: 首页>>代码示例>>PHP>>正文


PHP AbstractModel::getFieldTypes方法代码示例

本文整理汇总了PHP中AbstractModel::getFieldTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractModel::getFieldTypes方法的具体用法?PHP AbstractModel::getFieldTypes怎么用?PHP AbstractModel::getFieldTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AbstractModel的用法示例。


在下文中一共展示了AbstractModel::getFieldTypes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkFieldList

 /**
  * @param AbstractModel $className
  * @return array
  */
 protected final function checkFieldList($className)
 {
     $errors = [];
     // on vérifie d'abord que la table est définie
     $tableName = $className::getTableName();
     if ($tableName === null || !is_string($tableName) || strlen($tableName) == 0) {
         $errors[] = "undefined table name";
     }
     $fieldList = $className::getFieldList();
     if ($fieldList === null) {
         $errors[] = "undefined field list";
     } elseif (!is_array($fieldList)) {
         $errors[] = "field list is not an array";
     } else {
         foreach ($fieldList as $fieldName => $fieldInfos) {
             if (!is_string($fieldName) || strlen($fieldName) == 0) {
                 $errors[] = "undefined field name in field list";
             } else {
                 if (!isset($fieldInfos['type'])) {
                     $errors[] = "undefined field type for field named " . $fieldName;
                 } elseif (!in_array($fieldInfos['type'], AbstractModel::getFieldTypes())) {
                     $errors[] = "unknown field type for field named " . $fieldName . " : " . $fieldInfos['type'];
                 }
                 if (!isset($fieldInfos['required'])) {
                     $fieldList[$fieldName]['required'] = false;
                 } elseif (!is_bool($fieldInfos['required'])) {
                     $errors[] = "invalid required value for field named " . $fieldName . " : " . $fieldInfos['required'];
                 }
                 if (!isset($fieldInfos['size'])) {
                     $fieldList[$fieldName]['size'] = 0;
                 } elseif ($fieldInfos['type'] == 'float' && preg_match('#[0-9]+,[0-9]+#', $fieldInfos['size']) === false) {
                     $errors[] = "invalid size for field named " . $fieldName . " (" . $fieldInfos['type'] . ") : " . $fieldInfos['size'];
                 } elseif ($fieldInfos['type'] != 'float' && !is_int($fieldInfos['size'])) {
                     $errors[] = "size must be integer for field named " . $fieldName . " (" . $fieldInfos['type'] . ") : " . $fieldInfos['size'];
                 }
             }
         }
     }
     $relationList = $className::getRelationList();
     if ($relationList === null) {
         $errors[] = "undefined relation list";
     } elseif (!is_array($relationList)) {
         $errors[] = "relation list is not an array";
     } else {
         foreach ($relationList as $relation) {
             if (!isset($relation['field'])) {
                 $errors[] = "missing field on relation";
             }
             if (!isset($relation['class'])) {
                 $errors[] = "missing class on relation";
             }
             if (!isset($fieldList[$relation['field']])) {
                 $errors[] = "unknown field name in relation " . $relation['field'];
             }
             if (!is_subclass_of($relation['class'], '\\Bixev\\ORM\\AbstractModel')) {
                 $errors[] = "relation is not a model " . $relation['class'];
             }
         }
     }
     return $errors;
 }
开发者ID:bixev,项目名称:light-orm,代码行数:65,代码来源:Check.php


注:本文中的AbstractModel::getFieldTypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。