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


PHP Column::setType方法代码示例

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


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

示例1: populateFromOptions

 protected function populateFromOptions($options)
 {
     foreach ($options as $name => $attrs) {
         $column = new Column($name);
         if (isset($attrs['field'])) {
             $column->setFieldName($attrs['field']);
         }
         if (isset($attrs['type'])) {
             $column->setType($attrs['type']);
         }
         if (isset($attrs['sortable'])) {
             $column->setSortable($attrs['sortable']);
         }
         if (isset($attrs['label'])) {
             $column->setLabel($attrs['label']);
         }
         if (isset($attrs['format'])) {
             $column->setFormat($attrs['format']);
         }
         if (isset($attrs['format_function'])) {
             $column->setFormatFunction($attrs['format_function']);
         }
         if (isset($attrs['template'])) {
             $column->setTemplate($attrs['template']);
         }
         if (isset($attrs['boolean_actions'])) {
             $column->setBooleanActions($attrs['boolean_actions']);
         }
         if (isset($attrs['get_methods'])) {
             $column->setMethods($attrs['get_methods']);
         }
         $this->add($column);
     }
 }
开发者ID:senthilkumar3282,项目名称:LyraAdminBundle,代码行数:34,代码来源:ColumnCollection.php

示例2: createEnumColumn

 public function createEnumColumn($defaultValues, $defaultValue)
 {
     $column = new Column();
     $column->setType(PropelTypes::ENUM);
     $column->setValueSet($defaultValues);
     $column->setDefaultValue($defaultValue);
     return $column;
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:8,代码来源:DefaultPlatformTest.php

示例3: __construct

 /**
  * Constructs an instance from a list of column headers as returned by the
  * Google Analytics API.
  *
  * @param array $headers
  * @param Google\Analytics\API $api
  */
 public function __construct(array $headers, API $api)
 {
     $headerCount = count($headers);
     for ($i = 0; $i < $headerCount; $i++) {
         self::_validateHeader($headers[$i]);
         try {
             $column = $api->getColumn($headers[$i]['name']);
         } catch (InvalidArgumentException $e) {
             /* I don't expect this to happen but in case it does, we can
             			create a representation of the column by building it on the
             			fly, though it will be missing most of the available
             			properties. */
             $column = new Column();
             $column->setID(API::addPrefix($headers[$i]['name']));
             $column->setType($headers[$i]['columnType']);
             $column->setDataType($headers[$i]['dataType']);
         }
         $this->_columns[] = $column;
         $this->_columnIndicesByName[$column->getName()] = $i;
     }
 }
开发者ID:performics,项目名称:ga-cli-api,代码行数:28,代码来源:GaDataColumnHeaderCollection.class.php

示例4: setColumns

 /**
  * Creates the column from a given array
  *
  * @param array $columns
  */
 public function setColumns($columns)
 {
     if (false == is_array($columns)) {
         return;
     }
     foreach ($columns as $name => $options) {
         $column = new Column();
         $type = $this->getOptionByKey("type", $options);
         $length = $this->getOptionByKey("length", $options);
         $notNull = $this->getOptionByKey("notNull", $options);
         $autoIncrement = $this->getOptionByKey("autoIncrement", $options);
         $index = $this->getOptionByKey("index", $options);
         $collate = $this->getOptionByKey("collate", $options);
         $column->setName($name);
         // Set all options if set
         if (false != $type) {
             $column->setType($type);
         }
         if (false != $length) {
             $column->setLength($length);
         }
         if (false != $notNull) {
             $column->setNotNull($notNull);
         }
         if (false != $autoIncrement) {
             $column->setAutoIncrement($autoIncrement);
         }
         if (false != $index) {
             $column->setIndex($index);
         }
         if (false != $collate) {
             $column->setCollate($collate);
         }
         // Add column
         $this->columns[] = $column;
     }
 }
开发者ID:fewlines,项目名称:component,代码行数:42,代码来源:Table.php

示例5: _refreshColumnMetadata

 /**
  * Populates the properties that store cached dimensions and metrics,
  * either from the database or from the API directly, depending on when
  * the data that we have was last fetched.
  */
 private function _refreshColumnMetadata()
 {
     /* If we're not using a database, the best we can do is to cache the
        column metadata for the duration of this process' existence. */
     if (self::$_dbConn) {
         try {
             $lastFetchData = self::_getLastFetchData('google_analytics_api_columns');
             if ($lastFetchData) {
                 $fetchDate = (int) $lastFetchData['fetch_date'];
                 $etag = $lastFetchData['etag'];
             } else {
                 $fetchDate = null;
                 $etag = null;
             }
             $columns = null;
             $newETag = null;
             if ($this->_bypassColumnCache || !$fetchDate || $fetchDate <= time() - GOOGLE_ANALYTICS_API_METADATA_CACHE_DURATION) {
                 $this->_bypassColumnCache = false;
                 $request = new APIRequest('metadata/ga/columns');
                 if ($etag) {
                     $request->setHeader('If-None-Match: ' . $etag);
                 }
                 $columns = $this->_makeRequest($request);
                 if ($columns) {
                     $stmt = self::$_DB_STATEMENTS['google_analytics_api_columns']['insert'];
                     foreach ($columns as $column) {
                         $stmt->bindValue(':name', $column->getName(), \PDO::PARAM_STR);
                         $stmt->bindValue(':type', $column->getType(), \PDO::PARAM_STR);
                         $stmt->bindValue(':data_type', $column->getDataType(), \PDO::PARAM_STR);
                         $stmt->bindValue(':replaced_by', $column->getReplacementColumn(), \PDO::PARAM_STR);
                         $stmt->bindValue(':group', $column->getGroup(), \PDO::PARAM_STR);
                         $stmt->bindValue(':ui_name', $column->getUIName(), \PDO::PARAM_STR);
                         $stmt->bindValue(':description', $column->getDescription(), \PDO::PARAM_STR);
                         $stmt->bindValue(':calculation', $column->getCalculation(), \PDO::PARAM_STR);
                         $stmt->bindValue(':min_template_index', $column->getMinTemplateIndex(), \PDO::PARAM_INT);
                         $stmt->bindValue(':max_template_index', $column->getMaxTemplateIndex(), \PDO::PARAM_INT);
                         $stmt->bindValue(':min_template_index_premium', $column->getPremiumMinTemplateIndex(), \PDO::PARAM_INT);
                         $stmt->bindValue(':max_template_index_premium', $column->getPremiumMaxTemplateIndex(), \PDO::PARAM_INT);
                         $stmt->bindValue(':allowed_in_segments', $column->isAllowedInSegments(), \PDO::PARAM_INT);
                         $stmt->bindValue(':deprecated', $column->isDeprecated(), \PDO::PARAM_INT);
                         $stmt->execute();
                     }
                     $stmt = null;
                 }
                 if (array_key_exists('etag', $this->_responseParsed) && $this->_responseParsed['etag']) {
                     $newETag = $this->_responseParsed['etag'];
                 } else {
                     $responseHeader = $this->getResponseHeaderAsAssociativeArray();
                     if (array_key_exists('ETag', $responseHeader) && $responseHeader['ETag']) {
                         $newETag = $responseHeader['ETag'];
                     }
                 }
                 if ($newETag) {
                     self::_storeFetchData('google_analytics_api_columns', count($columns), $newETag);
                 }
             }
             if (!$columns) {
                 $columns = array();
                 $stmt = self::$_dbConn->query('SELECT * FROM google_analytics_api_columns');
                 $stmt->bindColumn('name', $name, \PDO::PARAM_STR);
                 $stmt->bindColumn('type', $type, \PDO::PARAM_STR);
                 $stmt->bindColumn('data_type', $dataType, \PDO::PARAM_STR);
                 $stmt->bindColumn('replaced_by', $replacement, \PDO::PARAM_STR);
                 $stmt->bindColumn('group', $group, \PDO::PARAM_STR);
                 $stmt->bindColumn('ui_name', $uiName, \PDO::PARAM_STR);
                 $stmt->bindColumn('description', $description, \PDO::PARAM_STR);
                 $stmt->bindColumn('calculation', $calculation, \PDO::PARAM_STR);
                 /* Null values get cast to zeros if I bind them as
                    integers, so we'll rely on the object's setter to take care
                    of the type casting. */
                 $stmt->bindColumn('min_template_index', $minTemplateIndex, \PDO::PARAM_STR);
                 $stmt->bindColumn('max_template_index', $maxTemplateIndex, \PDO::PARAM_STR);
                 $stmt->bindColumn('min_template_index_premium', $minTemplateIndexPremium, \PDO::PARAM_STR);
                 $stmt->bindColumn('max_template_index_premium', $maxTemplateIndexPremium, \PDO::PARAM_STR);
                 $stmt->bindColumn('allowed_in_segments', $allowedInSegments, \PDO::PARAM_BOOL);
                 $stmt->bindColumn('deprecated', $deprecated, \PDO::PARAM_BOOL);
                 while ($stmt->fetch(\PDO::FETCH_BOUND)) {
                     $column = new Column();
                     $column->setID('ga:' . $name);
                     $column->setReplacementColumn($replacement);
                     $column->setType($type);
                     $column->setDataType($dataType);
                     $column->setGroup($group);
                     $column->setUIName($uiName);
                     $column->setDescription($description);
                     $column->setCalculation($calculation);
                     if ($minTemplateIndex !== null) {
                         $column->setMinTemplateIndex($minTemplateIndex);
                     }
                     if ($maxTemplateIndex !== null) {
                         $column->setMaxTemplateIndex($maxTemplateIndex);
                     }
                     if ($minTemplateIndexPremium !== null) {
                         $column->setPremiumMinTemplateIndex($minTemplateIndexPremium);
                     }
//.........这里部分代码省略.........
开发者ID:performics,项目名称:ga-cli-api,代码行数:101,代码来源:API.class.php

示例6: testColumnIsFKAndPK

 public function testColumnIsFKAndPK()
 {
     $column = new Column();
     $column->setName('id');
     $column->setPrimaryKey(true);
     $column->setAutoIncrement(true);
     $column->setType('integer');
     $table = new Table();
     $table->setCommonName('table_one');
     $table->addColumn($column);
     $db = new Database();
     $db->setName('MultipleTables');
     $db->addTable($table);
     $column = new Column();
     $column->setName('id');
     $column->setPrimaryKey(true);
     $column->setAutoIncrement(true);
     $column->setType('integer');
     $c2 = new Column();
     $c2->setPrimaryKey(true);
     $c2->setName('foreign_id');
     $c2->setType('integer');
     $table = new Table();
     $table->setCommonName('table_two');
     $table->addColumn($column);
     $table->addColumn($c2);
     $fk = new ForeignKey();
     $fk->setName('FK_1');
     $fk->addReference('foreign_id', 'id');
     $fk->setForeignTableCommonName('table_one');
     $table->addForeignKey($fk);
     $db->addTable($table);
     $expected = implode("\n", array('digraph G {', 'nodetable_one [label="{<table>table_one|<cols>id (integer) [PK]\\l}", shape=record];', 'nodetable_two [label="{<table>table_two|<cols>id (integer) [PK]\\lforeign_id (integer) [FK] [PK]\\l}", shape=record];', 'nodetable_two:cols -> nodetable_one:table [label="foreign_id=id"];', '}', ''));
     $this->assertEquals($expected, PropelDotGenerator::create($db));
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:35,代码来源:PropelDotGeneratorTest.php

示例7: testIsPhpArrayType

 public function testIsPhpArrayType()
 {
     $column = new Column();
     $this->assertFalse($column->isPhpArrayType());
     $column->setType(PropelTypes::PHP_ARRAY);
     $this->assertTrue($column->isPhpArrayType());
 }
开发者ID:rozwell,项目名称:Propel,代码行数:7,代码来源:ColumnTest.php

示例8: parseToDataObj

 public function parseToDataObj()
 {
     $file_buffer = strtolower($this->_file_buffer);
     $file_buffer = str_replace("\n", ' ', $file_buffer);
     $file_buffer = str_replace("\t", ' ', $file_buffer);
     $file_buffer = preg_replace('/\\s+/si', " ", $file_buffer);
     $tables = explode('create table ', $file_buffer);
     // first ones throw away since all table definitions start with "create table" and this is exploding by it
     array_shift($tables);
     $db = array();
     // empty table array
     foreach ($tables as $table) {
         $TableDef = new Table();
         trim($table);
         preg_match('/`(.*?)`/', $table, $matches);
         $TableDef->name = trim($matches[1]);
         unset($matches);
         $column_pieces = explode('`' . $TableDef->name . '`', $table);
         $table_columns = $column_pieces[1];
         $columns = explode(',', $table_columns);
         foreach ($columns as $column) {
             $Col = new Column();
             $column = ' ' . trim($column) . ' ';
             // strip out things before a  ` unless it's UNIQUE or PRIMARY, and then parse those.
             if (stripos($column, 'unique') == 1) {
                 $keys = explode('`', $column);
                 foreach ($keys as $key) {
                     if (isset($TableDef->columns[$key])) {
                         $TableDef->columns[$key]->unique = true;
                         $TableDef->unique_keys[] = $key;
                     }
                 }
             } else {
                 if (stripos($column, 'primary') == 1) {
                     $keys = explode('`', $column);
                     foreach ($keys as $key) {
                         if (isset($TableDef->columns[$key])) {
                             $TableDef->columns[$key]->primary = true;
                             $TableDef->primary_keys[] = $key;
                         }
                     }
                 } else {
                     if (stripos($column, 'index') == 1) {
                         $keys = explode('`', $column);
                         foreach ($keys as $key) {
                             if (isset($TableDef->columns[$key])) {
                                 $TableDef->columns[$key]->index = true;
                                 $TableDef->index_keys[] = $key;
                             }
                         }
                     } else {
                         $original_column = $column;
                         // do appropriate stuff
                         $column = preg_replace('/.*?`(.*?)/', '`$1', $column, 1);
                         // thank you mr gregory
                         preg_match_all('/`([a-zA-Z0-9_]+)`[\\s]*([\\w]+)[\\s]*\\(*[\\s]*([0-9]*)[\\s]*\\)*[\\s]+([^,]+)./', $column, $matches);
                         if (!isset($matches[1][0])) {
                             print_r($original_column);
                             continue;
                         }
                         $Col->name = $matches[1][0];
                         $Col->setType($this->convertToStandardType($matches[2][0]));
                         $size_array = $this->convertToStandardSizeArray($matches[3][0]);
                         $Col->setSize($size_array[0], $size_array[1]);
                         $column = ' ' . trim($matches[4][0]) . ' ';
                         unset($matches);
                         if (substr($Col->name, -3) == '_id') {
                             $TableDef->possible_foreign_keys[] = $Col->name;
                         }
                         // match for binary, unsigned, or unsigned zerofill for attributes
                         if (stripos($column, 'unsigned zerofill')) {
                             $Col->setAttributes('unsigned zerofill');
                         } else {
                             if (stripos($column, '')) {
                                 $Col->setAttributes('unsigned');
                             } else {
                                 if (stripos($column, 'binary')) {
                                     $Col->setAttributes('binary');
                                 }
                             }
                         }
                         // match "null" or "not null" and define the nullable attribute
                         if (stripos($column, 'not null')) {
                             $Col->nullable = false;
                         } else {
                             $Col->nullable = true;
                         }
                         // match primary, unique, index, or fulltext for index
                         if (stripos($column, ' primary')) {
                             $Col->primary = true;
                             $TableDef->primary_keys[] = $Col->name;
                         } else {
                             if (stripos($column, ' unique')) {
                                 $Col->unique = true;
                                 $TableDef->unique_keys[] = $Col->name;
                             } else {
                                 if (stripos($column, ' index')) {
                                     $Col->index = true;
                                     $TableDef->index_keys[] = $Col->name;
                                 }
//.........这里部分代码省略.........
开发者ID:jeffreytgilbert,项目名称:Db2Obj,代码行数:101,代码来源:SQLite32Obj.php


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