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


PHP Column::cast方法代码示例

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


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

示例1: create_column

 public function create_column(&$column)
 {
     $c = new Column();
     $c->inflected_name = Inflector::instance()->variablize($column['field']);
     $c->name = $column['field'];
     $c->nullable = $column['null'] === 'YES' ? true : false;
     $c->pk = $column['key'] === 'PRI' ? true : false;
     $c->auto_increment = $column['extra'] === 'auto_increment' ? true : false;
     if ($column['type'] == 'timestamp' || $column['type'] == 'datetime') {
         $c->raw_type = 'datetime';
         $c->length = 19;
     } elseif ($column['type'] == 'date') {
         $c->raw_type = 'date';
         $c->length = 10;
     } else {
         preg_match('/^([A-Za-z0-9_]+)(\\(([0-9]+(,[0-9]+)?)\\))?/', $column['type'], $matches);
         $c->raw_type = count($matches) > 0 ? $matches[1] : $column['type'];
         if (count($matches) >= 4) {
             $c->length = intval($matches[3]);
         }
     }
     $c->map_raw_type();
     $c->default = $c->cast($column['default']);
     return $c;
 }
开发者ID:469306621,项目名称:Languages,代码行数:25,代码来源:MysqlAdapter.php

示例2: createColumn

 public function createColumn(&$column)
 {
     $c = new Column();
     $c->inflectedName = Inflector::instance()->variablize($column['field']);
     $c->name = $column['field'];
     $c->nullable = $column['not_nullable'] ? false : true;
     $c->pk = $column['pk'] ? true : false;
     $c->autoIncrement = false;
     if (substr($column['type'], 0, 9) == 'timestamp') {
         $c->rawType = 'datetime';
         $c->length = 19;
     } elseif ($column['type'] == 'date') {
         $c->rawType = 'date';
         $c->length = 10;
     } else {
         preg_match('/^([A-Za-z0-9_]+)(\\(([0-9]+(,[0-9]+)?)\\))?/', $column['type'], $matches);
         $c->rawType = count($matches) > 0 ? $matches[1] : $column['type'];
         $c->length = count($matches) >= 4 ? intval($matches[3]) : intval($column['attlen']);
         if ($c->length < 0) {
             $c->length = null;
         }
     }
     $c->mapRawType();
     if ($column['default']) {
         preg_match('/^nextval\\(\'(.*)\'\\)$/', $column['default'], $matches);
         if (count($matches) == 2) {
             $c->sequence = $matches[1];
         } else {
             $c->default = $c->cast($column['default'], $this);
         }
     }
     return $c;
 }
开发者ID:ruri,项目名称:php-activerecord-camelcased,代码行数:33,代码来源:PgsqlAdapter.php

示例3: create_column

 public function create_column($column)
 {
     $c = new Column();
     $c->inflected_name = Inflector::instance()->variablize($column['name']);
     $c->name = $column['name'];
     $c->nullable = $column['notnull'] ? false : true;
     $c->pk = $column['pk'] ? true : false;
     $c->auto_increment = $column['type'] == 'INTEGER' && $c->pk;
     $column['type'] = preg_replace('/ +/', ' ', $column['type']);
     $column['type'] = str_replace(array('(', ')'), ' ', $column['type']);
     $column['type'] = Utils::squeeze(' ', $column['type']);
     $matches = explode(' ', $column['type']);
     if (count($matches) > 0) {
         $c->raw_type = strtolower($matches[0]);
         if (count($matches) > 1) {
             $c->length = intval($matches[1]);
         }
     }
     $c->map_raw_type();
     if ($c->type == Column::DATETIME) {
         $c->length = 19;
     } elseif ($c->type == Column::DATE) {
         $c->length = 10;
     }
     // From SQLite3 docs: The value is a signed integer, stored in 1, 2, 3, 4, 6,
     // or 8 bytes depending on the magnitude of the value.
     // so is it ok to assume it's possible an int can always go up to 8 bytes?
     if ($c->type == Column::INTEGER && !$c->length) {
         $c->length = 8;
     }
     $c->default = $c->cast($column['dflt_value']);
     return $c;
 }
开发者ID:469306621,项目名称:Languages,代码行数:33,代码来源:PgsqlAdapter.php


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