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


PHP ColumnMap::isForeignKey方法代码示例

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


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

示例1: getValidatorOptionsForColumn

 /**
  * Returns a PHP string representing options to pass to a validator for a given column.
  *
  * @param  ColumnMap $column  A ColumnMap object
  *
  * @return string    The options to pass to the validator as a PHP string
  */
 public function getValidatorOptionsForColumn(ColumnMap $column)
 {
     $options = array();
     if ($column->isForeignKey()) {
         $map = call_user_func(array(constant($this->getForeignTable($column)->getClassname() . '::PEER'), 'getTableMap'));
         foreach ($map->getColumns() as $primaryKey) {
             if ($primaryKey->isPrimaryKey()) {
                 break;
             }
         }
         $options[] = sprintf('\'model\' => \'%s\', \'column\' => \'%s\'', $this->getForeignTable($column)->getClassname(), strtolower($primaryKey->getColumnName()));
     } else {
         if ($column->isPrimaryKey()) {
             $options[] = sprintf('\'model\' => \'%s\', \'column\' => \'%s\'', $column->getTable()->getClassname(), strtolower($column->getColumnName()));
         } else {
             switch ($column->getType()) {
                 case PropelColumnTypes::CLOB:
                 case PropelColumnTypes::CHAR:
                 case PropelColumnTypes::VARCHAR:
                 case PropelColumnTypes::LONGVARCHAR:
                     if ($column->getSize()) {
                         $options[] = sprintf('\'max_length\' => %s', $column->getSize());
                     }
                     break;
             }
         }
     }
     if (!$column->isNotNull() || $column->isPrimaryKey()) {
         $options[] = '\'required\' => false';
     }
     return count($options) ? sprintf('array(%s)', implode(', ', $options)) : '';
 }
开发者ID:broschb,项目名称:cyclebrain,代码行数:39,代码来源:sfPropelFormGenerator.class.php

示例2: getType

 public function getType(ColumnMap $column)
 {
     if ($column->isForeignKey()) {
         return 'ForeignKey';
     }
     switch ($column->getType()) {
         case PropelColumnTypes::BOOLEAN:
             return 'Boolean';
         case PropelColumnTypes::DATE:
         case PropelColumnTypes::TIME:
         case PropelColumnTypes::TIMESTAMP:
             return 'Date';
         case PropelColumnTypes::DOUBLE:
         case PropelColumnTypes::FLOAT:
         case PropelColumnTypes::NUMERIC:
         case PropelColumnTypes::DECIMAL:
         case PropelColumnTypes::REAL:
         case PropelColumnTypes::INTEGER:
         case PropelColumnTypes::SMALLINT:
         case PropelColumnTypes::TINYINT:
         case PropelColumnTypes::BIGINT:
             return 'Number';
         default:
             return 'Text';
     }
 }
开发者ID:xfifix,项目名称:symfony-1.4,代码行数:26,代码来源:sfPropelFormFilterGenerator.class.php

示例3: getValidatorOptionsForColumn

 /**
  * Returns a PHP string representing options to pass to a validator for a given column.
  *
  * @param  ColumnMap $column  A ColumnMap object
  *
  * @return string    The options to pass to the validator as a PHP string
  */
 public function getValidatorOptionsForColumn(ColumnMap $column)
 {
     $options = array();
     if ($column->isForeignKey()) {
         $options[] = sprintf('\'model\' => \'%s\', \'column\' => \'%s\'', $this->getForeignTable($column)->getClassname(), $this->translateColumnName($column, true));
     } else {
         if ($column->isPrimaryKey()) {
             $options[] = sprintf('\'model\' => \'%s\', \'column\' => \'%s\'', $column->getTable()->getClassname(), $this->translateColumnName($column));
         } else {
             switch ($column->getType()) {
                 case PropelColumnTypes::CLOB:
                 case PropelColumnTypes::CHAR:
                 case PropelColumnTypes::VARCHAR:
                 case PropelColumnTypes::LONGVARCHAR:
                     if ($column->getSize()) {
                         $options[] = sprintf('\'max_length\' => %s', $column->getSize());
                     }
                     break;
                 case PropelColumnTypes::TINYINT:
                     $options[] = sprintf('\'min\' => %s, \'max\' => %s', -128, 127);
                     break;
                 case PropelColumnTypes::SMALLINT:
                     $options[] = sprintf('\'min\' => %s, \'max\' => %s', -32768, 32767);
                     break;
                 case PropelColumnTypes::INTEGER:
                     $options[] = sprintf('\'min\' => %s, \'max\' => %s', -2147483648, 2147483647);
                     break;
                 case PropelColumnTypes::BIGINT:
                     $options[] = sprintf('\'min\' => %s, \'max\' => %s', -9.223372036854776E+18, 9223372036854775807);
                     break;
             }
         }
     }
     if (!$column->isNotNull() || $column->isPrimaryKey()) {
         $options[] = '\'required\' => false';
     }
     if (null !== $column->getDefaultValue()) {
         $options[] = sprintf('\'empty_value\' => \'%s\'', $column->getDefaultValue());
     }
     return count($options) ? sprintf('array(%s)', implode(', ', $options)) : '';
 }
开发者ID:bigcalm,项目名称:urlcatcher,代码行数:48,代码来源:sfPropelFormGenerator.class.php

示例4: getValidatorOptionsForColumn

 /**
  * Returns a PHP string representing options to pass to a validator for a given column.
  *
  * @param  ColumnMap $column  A ColumnMap object
  *
  * @return string    The options to pass to the validator as a PHP string
  */
 public function getValidatorOptionsForColumn(ColumnMap $column)
 {
     $options = array();
     if ($column->isForeignKey()) {
         $options[] = sprintf('\'model\' => \'%s\', \'column\' => \'%s\'', $this->getForeignTable($column)->getClassname(), $this->translateColumnName($column, true));
     } else {
         if ($column->isPrimaryKey()) {
             $options[] = sprintf('\'choices\' => array($this->getObject()->get%s()), \'empty_value\' => $this->getObject()->get%1$s()', $this->translateColumnName($column, false, BasePeer::TYPE_PHPNAME));
         } else {
             switch ($column->getType()) {
                 case PropelColumnTypes::CLOB:
                 case PropelColumnTypes::CHAR:
                 case PropelColumnTypes::VARCHAR:
                 case PropelColumnTypes::LONGVARCHAR:
                     if ($column->getSize()) {
                         $options[] = sprintf('\'max_length\' => %s', $column->getSize());
                     }
                     break;
                 case PropelColumnTypes::TINYINT:
                     $options[] = sprintf('\'min\' => %s, \'max\' => %s', -128, 127);
                     break;
                 case PropelColumnTypes::SMALLINT:
                     $options[] = sprintf('\'min\' => %s, \'max\' => %s', -32768, 32767);
                     break;
                 case PropelColumnTypes::INTEGER:
                     $options[] = sprintf('\'min\' => %s, \'max\' => %s', -2147483648, 2147483647);
                     break;
                 case PropelColumnTypes::BIGINT:
                     $options[] = sprintf('\'min\' => %s, \'max\' => %s', -9.223372036854776E+18, 9223372036854775807);
                     break;
                 case PropelColumnTypes::ENUM:
                     $valueSet = $column->getValueSet();
                     $options[] = sprintf("'choices' => %s", preg_replace('/[\\n\\r]+/', '', var_export($valueSet, true)));
                     break;
             }
         }
     }
     if (!$column->isNotNull() || $column->isPrimaryKey()) {
         $options[] = '\'required\' => false';
     }
     return count($options) ? sprintf('array(%s)', implode(', ', $options)) : '';
 }
开发者ID:propelorm,项目名称:sfPropelORMPlugin,代码行数:49,代码来源:sfPropelFormGenerator.class.php

示例5: getCrudColumnEditTag

  /**
   * Returns HTML code for a column in edit mode.
   *
   * @param ColumnMap $column  The column name
   * @param array  $params  The parameters
   *
   * @return string HTML code
   */
  public function getCrudColumnEditTag($column, $params = array())
  {
    $type = $column->getCreoleType();

    if ($column->isForeignKey())
    {
      if (!$column->isNotNull() && !isset($params['include_blank']))
      {
        $params['include_blank'] = true;
      }
      return $this->getPHPObjectHelper('select_tag', $column, $params, array('related_class' => $this->getRelatedClassName($column)));
    }
    else if ($type == CreoleTypes::DATE)
    {
      // rich=false not yet implemented
      return $this->getPHPObjectHelper('input_date_tag', $column, $params, array('rich' => true));
    }
    else if ($type == CreoleTypes::TIMESTAMP)
    {
      // rich=false not yet implemented
      return $this->getPHPObjectHelper('input_date_tag', $column, $params, array('rich' => true, 'withtime' => true));
    }
    else if ($type == CreoleTypes::BOOLEAN)
    {
      return $this->getPHPObjectHelper('checkbox_tag', $column, $params);
    }
    else if ($type == CreoleTypes::CHAR || $type == CreoleTypes::VARCHAR)
    {
      $fieldMin = $this->getParameterValue('defaults.edit.char_min', 20);
      $fieldMax = $this->getParameterValue('defaults.edit.char_max', 80);
      $size = ($column->getSize() > $fieldMin ? ($column->getSize() < $fieldMax ? $column->getSize() : $fieldMax) : $fieldMin);
      return $this->getPHPObjectHelper('input_tag', $column, $params, array('size' => $size));
    }
    else if ($type == CreoleTypes::INTEGER || $type == CreoleTypes::TINYINT || $type == CreoleTypes::SMALLINT || $type == CreoleTypes::BIGINT)
    {
      $size = $this->getParameterValue('defaults.edit.int_size', 7);
      return $this->getPHPObjectHelper('input_tag', $column, $params, array('size' => $size));
    }
    else if ($type == CreoleTypes::FLOAT || $type == CreoleTypes::DOUBLE || $type == CreoleTypes::DECIMAL || $type == CreoleTypes::NUMERIC || $type == CreoleTypes::REAL)
    {
      $size = $this->getParameterValue('defaults.edit.float_size', 7);
      return $this->getPHPObjectHelper('input_tag', $column, $params, array('size' => $size));
    }
    else if ($type == CreoleTypes::TEXT || $type == CreoleTypes::LONGVARCHAR)
    {
      $size = $this->getParameterValue('defaults.edit.text_size', '80x5');
      return $this->getPHPObjectHelper('textarea_tag', $column, $params, array('size' => $size));
    }
    else
    {
      return $this->getPHPObjectHelper('input_tag', $column, $params, array('disabled' => true));
    }
  }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:61,代码来源:sfCrudGenerator.class.php

示例6: getValidatorOptionsForColumn

 /**
  * Returns a PHP string representing options to pass to a validator for a given column.
  *
  * @param  ColumnMap $column  A ColumnMap object
  *
  * @return string    The options to pass to the validator as a PHP string
  */
 public function getValidatorOptionsForColumn(ColumnMap $column)
 {
     $options = array();
     if ($column->isForeignKey()) {
         $options[] = sprintf('\'model\' => \'%s\', \'column\' => \'%s\'', $this->getForeignTable($column)->getClassname(), $this->translateColumnName($column, true));
     } else {
         if ($column->isPrimaryKey()) {
             $options[] = sprintf('\'model\' => \'%s\', \'column\' => \'%s\'', $column->getTable()->getClassname(), $this->translateColumnName($column));
         } else {
             switch ($column->getType()) {
                 case PropelColumnTypes::CLOB:
                 case PropelColumnTypes::CHAR:
                 case PropelColumnTypes::VARCHAR:
                 case PropelColumnTypes::LONGVARCHAR:
                     if ($column->getSize()) {
                         $options[] = sprintf('\'max_length\' => %s', $column->getSize());
                     }
                     break;
             }
         }
     }
     if (!$column->isNotNull() || $column->isPrimaryKey()) {
         $options[] = '\'required\' => false';
     }
     return count($options) ? sprintf('array(%s)', implode(', ', $options)) : '';
 }
开发者ID:yasirgit,项目名称:afids,代码行数:33,代码来源:sfPropelFormGenerator.class.php

示例7: getRowValue

 /**
  * Gets value for row table
  * 
  * Swaps foreign creator_node_id values for their unique FQDN value. Note that the other
  * part(s) to a primary or foreign key is set by the creator and is the same in all nodes,
  * so may be hashed without causing difference problems between nodes.
  * 
  * @todo Better node table detection required (should use known prefix)
  * @todo Fix column name hardwiring
  * 
  * @param MeshingBaseObject $object
  * @param ColumnMap $columnMap
  * @return mixed 
  */
 protected function getRowValue(MeshingBaseObject $object, ColumnMap $columnMap)
 {
     // Get value for this column
     $columnName = $columnMap->getName();
     $value = $object->getByName($columnName, BasePeer::TYPE_RAW_COLNAME);
     // If the related table name ends with '_known_node' then we assume this is a
     // FK to a creator node ID.
     if ($columnMap->isForeignKey()) {
         $match = '_known_node';
         $isNodeTable = $match == substr($columnMap->getRelatedTableName(), -strlen($match));
         if ($isNodeTable && $columnMap->getRelatedColumnName() == 'ID') {
             $nodePeerName = $columnMap->getRelation()->getForeignTable()->getPeerClassname();
             $node = call_user_func(array($nodePeerName, 'retrieveByPK'), $value, $this->con);
             // If there is no related node, we really do have problems!
             if (!$node) {
                 $primaryKey = $object->getPrimaryKey();
                 if (is_array($primaryKey)) {
                     $primaryKey = '{' . implode(',', $primaryKey) . '}';
                 }
                 $type = get_class($object);
                 throw new Exception("Row {$primaryKey} in table '{$type}' points to a non-existent node row");
             }
             $value = $node->getFqdn();
         }
     }
     return $value;
 }
开发者ID:halfer,项目名称:Meshing,代码行数:41,代码来源:Basic.php


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