本文整理汇总了PHP中ColumnMap类的典型用法代码示例。如果您正苦于以下问题:PHP ColumnMap类的具体用法?PHP ColumnMap怎么用?PHP ColumnMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ColumnMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getPrimaryKeys
public function getPrimaryKeys()
{
$cm = new \ColumnMap('id', new \TableMap());
$cm->setType('INTEGER');
$cm->setPhpName('Id');
return array('id' => $cm);
}
开发者ID:gr-thao,项目名称:jobeet,代码行数:7,代码来源:ItemQuery.php
示例2: addCIRValidation
public static function addCIRValidation(TableMap $map, ColumnMap $column, $message = null)
{
$columnName = $column->getColumnName();
$value = $column->getRelatedTableName();
if (!isset($message)) {
$message = $value . " non trouvé";
}
$map->addValidator($columnName, "class", "utils.CIRValidator", $value, $message);
}
开发者ID:sandrineBeauche,项目名称:cookbookServer,代码行数:9,代码来源:CIRPeerUtils.php
示例3: bindValue
/**
* @see DBAdapter::bindValue()
*/
public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap)
{
if ($cMap->isTemporal()) {
$value = $this->formatTemporalValue($value, $cMap);
} elseif (is_resource($value) && $cMap->isLob()) {
// we always need to make sure that the stream is rewound, otherwise nothing will
// get written to database.
rewind($value);
// pdo_sqlsrv must have bind binaries using bindParam so that the PDO::SQLSRV_ENCODING_BINARY
// driver option can be utilized. This requires a unique blob parameter because the bindParam
// value is passed by reference and if we didn't do this then the referenced parameter value
// would change on the next loop
$blob = "blob" . $position;
${$blob} = $value;
return $stmt->bindParam($parameter, ${$blob}, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);
}
return $stmt->bindValue($parameter, $value, $cMap->getPdoType());
}
开发者ID:rubensayshi,项目名称:propelsandbox,代码行数:21,代码来源:DBSQLSRV.php
示例4: __construct
/**
* Create a new instance.
*
* @param Criteria $parent The outer class (this is an "inner" class).
* @param ColumnMap $column A Column object to help escaping the value
* @param mixed $value
* @param string $comparison, among ModelCriteria::MODEL_CLAUSE
* @param string $clause A simple pseudo-SQL clause, e.g. 'foo.BAR LIKE ?'
*/
public function __construct(Criteria $outer, $column, $value = null, $comparison = ModelCriteria::MODEL_CLAUSE, $clause)
{
$this->value = $value;
if ($column instanceof ColumnMap) {
$this->column = $column->getName();
$this->table = $column->getTable()->getName();
} else {
$dotPos = strrpos($column, '.');
if ($dotPos === false) {
// no dot => aliased column
$this->table = null;
$this->column = $column;
} else {
$this->table = substr($column, 0, $dotPos);
$this->column = substr($column, $dotPos + 1, strlen($column));
}
}
$this->comparison = $comparison === null ? Criteria::EQUAL : $comparison;
$this->clause = $clause;
$this->init($outer);
}
开发者ID:nextbigsound,项目名称:propel-orm,代码行数:30,代码来源:ModelCriterion.php
示例5: 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
示例6: testPrimaryStringAddConfiguredColumn
public function testPrimaryStringAddConfiguredColumn()
{
$this->assertFalse($this->tmap->hasPrimaryStringColumn(), 'hasPrimaryStringColumn() returns false while none set.');
$column = new ColumnMap('BAR', $this->tmap);
$column->setPhpName('Bar');
$column->setType('VARCHAR');
$column->setPrimaryString(true);
$this->tmap->addConfiguredColumn($column);
$this->assertTrue($this->tmap->hasPrimaryStringColumn(), 'hasPrimaryStringColumn() returns true after adding pkStr column.');
$this->assertEquals($column, $this->tmap->getPrimaryStringColumn(), 'getPrimaryStringColumn() returns correct column.');
}
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:11,代码来源:TableMapTest.php
示例7: convertValueForColumn
/**
* Converts value for some column types
*
* @param mixed $value The value to convert
* @param ColumnMap $colMap The ColumnMap object
* @return mixed The converted value
*/
protected function convertValueForColumn($value, ColumnMap $colMap)
{
if ($colMap->getType() == 'OBJECT' && is_object($value)) {
if (is_array($value)) {
$value = array_map('serialize', $value);
} else {
$value = serialize($value);
}
} elseif ($colMap->getType() == 'ARRAY' && is_array($value)) {
$value = '| ' . implode(' | ', $value) . ' |';
} elseif ($colMap->getType() == 'ENUM') {
if (is_array($value)) {
$value = array_map(array($colMap, 'getValueSetKey'), $value);
} else {
$value = $colMap->getValueSetKey($value);
}
}
return $value;
}
开发者ID:kcornejo,项目名称:estadistica,代码行数:26,代码来源:ModelCriteria.php
示例8: addColumnMap
/**
* Adds a given column map to the data map.
*
* @param \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap $columnMap The column map
* @return void
*/
public function addColumnMap(ColumnMap $columnMap)
{
$this->columnMaps[$columnMap->getPropertyName()] = $columnMap;
}
开发者ID:,项目名称:,代码行数:10,代码来源:
示例9: 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
示例10: 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
示例11: getColumnName
protected function getColumnName(\ColumnMap $column)
{
return strtolower($column->getName());
}
开发者ID:bombayworks,项目名称:currycms,代码行数:4,代码来源:ModelForm.php
示例12: getColumnNameAndOptions
protected function getColumnNameAndOptions(ColumnMap $column)
{
$name = strtolower($column->getName());
$relation = $column->getRelation();
$options = array('label' => $relation ? $relation->getName() : ucfirst(str_replace("_", " ", $name)), 'id' => 'table-' . str_replace('_', '-', $column->getTableName()) . '-column-' . str_replace("_", "-", $name) . rand());
return array($name, $options);
}
开发者ID:varvanin,项目名称:currycms,代码行数:7,代码来源:ModelForm.php
示例13: extractValueMethod
/**
* Extract the value method and the required parameters for it, for given a ColumnMap's type.
* Return an Array holding the value method as first value and its parameters as the second one.
*
* @param ColumnMap $column
* @return Array
*/
public static function extractValueMethod(ColumnMap $column)
{
$value_method = 'get' . $column->getPhpName();
$params = null;
if (in_array($column->getType(), array(PropelColumnTypes::BU_DATE, PropelColumnTypes::DATE))) {
$params = ncChangeLogConfigHandler::getDateFormat();
} elseif (in_array($column->getType(), array(PropelColumnTypes::BU_TIMESTAMP, PropelColumnTypes::TIMESTAMP))) {
$params = ncChangeLogConfigHandler::getDateTimeFormat();
} elseif ($column->getType() == PropelColumnTypes::TIME) {
$params = ncChangeLogConfigHandler::getTimeFormat();
}
return array($value_method, $params);
}
开发者ID:nvidela,项目名称:kimkelen,代码行数:20,代码来源:ncPropelChangeLogBehavior.class.php
示例14: validFieldNameProvider
public function validFieldNameProvider()
{
$className = '\\Foo\\Book';
$options = array('foo' => 'bar');
// table maps
$emptyTableMap = new \TableMap();
$authorTable = new \TableMap();
$authorTable->setClassName('\\Foo\\Author');
$resellerTable = new \TableMap();
$resellerTable->setClassName('\\Foo\\Reseller');
$relationsTableMap = $this->getMock('\\TableMap');
// relations
$mainAuthorRelation = new \RelationMap('MainAuthor');
$mainAuthorRelation->setType(\RelationMap::MANY_TO_ONE);
$mainAuthorRelation->setForeignTable($authorTable);
$authorRelation = new \RelationMap('Author');
$authorRelation->setType(\RelationMap::ONE_TO_MANY);
$authorRelation->setForeignTable($authorTable);
$resellerRelation = new \RelationMap('Reseller');
$resellerRelation->setType(\RelationMap::MANY_TO_MANY);
$resellerRelation->setLocalTable($resellerTable);
// configure table maps mocks
$relationsTableMap->expects($this->any())->method('getRelations')->will($this->returnValue(array($mainAuthorRelation, $authorRelation, $resellerRelation)));
// columns
$titleColumn = new \ColumnMap('Title', $emptyTableMap);
$titleColumn->setType('text');
$titleColumn->setPhpName('Title');
$titleFieldMapping = array('id' => false, 'type' => 'text', 'fieldName' => 'Title');
return array(array(null, array(), $className, 'Title', $options, array('type' => null, 'association_mapping' => null, 'field_mapping' => null)), array($emptyTableMap, array(), $className, 'Title', $options, array('type' => null, 'association_mapping' => null, 'field_mapping' => null)), array($emptyTableMap, array($titleColumn), $className, 'Title', $options, array('type' => 'text', 'association_mapping' => null, 'field_mapping' => $titleFieldMapping)), array($relationsTableMap, array($titleColumn), $className, 'MainAuthor', $options, array('type' => \RelationMap::MANY_TO_ONE, 'association_mapping' => array('targetEntity' => '\\Foo\\Author', 'type' => \RelationMap::MANY_TO_ONE), 'field_mapping' => null)), array($relationsTableMap, array($titleColumn), $className, 'Authors', $options, array('type' => \RelationMap::ONE_TO_MANY, 'association_mapping' => array('targetEntity' => '\\Foo\\Author', 'type' => \RelationMap::ONE_TO_MANY), 'field_mapping' => null)), array($relationsTableMap, array($titleColumn), $className, 'Resellers', $options, array('type' => \RelationMap::MANY_TO_MANY, 'association_mapping' => array('targetEntity' => '\\Foo\\Reseller', 'type' => \RelationMap::MANY_TO_MANY), 'field_mapping' => null)));
}
开发者ID:kosolapovvp,项目名称:SonataPropelAdminBundle,代码行数:30,代码来源:ModelManagerTest.php
示例15: bindValue
/**
* @see DBAdapter::bindValue()
*
* @param PDOStatement $stmt
* @param string $parameter
* @param mixed $value
* @param ColumnMap $cMap
* @param null|integer $position
*
* @return boolean
*/
public function bindValue(PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null)
{
$pdoType = $cMap->getPdoType();
// FIXME - This is a temporary hack to get around apparent bugs w/ PDO+MYSQL
// See http://pecl.php.net/bugs/bug.php?id=9919
if ($pdoType == PDO::PARAM_BOOL) {
$value = (int) $value;
$pdoType = PDO::PARAM_INT;
return $stmt->bindValue($parameter, $value, $pdoType);
} elseif ($cMap->isTemporal()) {
$value = $this->formatTemporalValue($value, $cMap);
} elseif (is_resource($value) && $cMap->isLob()) {
// we always need to make sure that the stream is rewound, otherwise nothing will
// get written to database.
rewind($value);
}
return $stmt->bindValue($parameter, $value, $pdoType);
}
开发者ID:keneanung,项目名称:gw2spidy,代码行数:29,代码来源:DBMySQL.php
示例16: 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
示例17: _getColumnRawValue
protected static function _getColumnRawValue(ColumnMap $column, $value)
{
if ($value === null) {
return null;
}
switch ($column->getType()) {
case PropelColumnTypes::ENUM:
$valueSet = $column->getValueSet();
return array_search($value, $valueSet);
case PropelColumnTypes::PHP_ARRAY:
return '| ' . implode(' | ', $value) . ' |';
case PropelColumnTypes::OBJECT:
return serialize($value);
}
return $value;
}
开发者ID:varvanin,项目名称:currycms,代码行数:16,代码来源:Propel.php
示例18: setManyToManyRelation
/**
* This method sets the configuration for a m:n relation based on
* the $TCA column configuration
*
* @param string|ColumnMap $columnMap The column map
* @param string $columnConfiguration The column configuration from $TCA
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedRelationException
* @return ColumnMap
*/
protected function setManyToManyRelation(ColumnMap $columnMap, $columnConfiguration)
{
if (isset($columnConfiguration['MM'])) {
$columnMap->setTypeOfRelation(ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY);
$columnMap->setChildTableName($columnConfiguration['foreign_table']);
$columnMap->setChildTableWhereStatement($columnConfiguration['foreign_table_where']);
$columnMap->setRelationTableName($columnConfiguration['MM']);
if (is_array($columnConfiguration['MM_match_fields'])) {
$columnMap->setRelationTableMatchFields($columnConfiguration['MM_match_fields']);
}
if (is_array($columnConfiguration['MM_insert_fields'])) {
$columnMap->setRelationTableInsertFields($columnConfiguration['MM_insert_fields']);
}
$columnMap->setRelationTableWhereStatement($columnConfiguration['MM_table_where']);
if (!empty($columnConfiguration['MM_opposite_field'])) {
$columnMap->setParentKeyFieldName('uid_foreign');
$columnMap->setChildKeyFieldName('uid_local');
$columnMap->setChildSortByFieldName('sorting_foreign');
} else {
$columnMap->setParentKeyFieldName('uid_local');
$columnMap->setChildKeyFieldName('uid_foreign');
$columnMap->setChildSortByFieldName('sorting');
}
} else {
throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedRelationException('The given information to build a many-to-many-relation was not sufficient. Check your TCA definitions. mm-relations with IRRE must have at least a defined "MM" or "foreign_selector".', 1268817963);
}
if ($this->getControlSection($columnMap->getRelationTableName()) !== null) {
$columnMap->setRelationTablePageIdColumnName('pid');
}
return $columnMap;
}
开发者ID:,项目名称:,代码行数:40,代码来源:
示例19: 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
示例20: getColumnValue
/**
* Get value for column to use in database dump.
*
* @param BaseObject $obj
* @param ColumnMap $column
* @return mixed
*/
protected static function getColumnValue(BaseObject $obj, ColumnMap $column)
{
switch ($column->getType()) {
case PropelColumnTypes::DATE:
return $obj->{'get' . $column->getPhpName()}('Y-m-d');
break;
case PropelColumnTypes::TIMESTAMP:
return $obj->{'get' . $column->getPhpName()}('Y-m-d H:i:s');
break;
case PropelColumnTypes::TIME:
return $obj->{'get' . $column->getPhpName()}('H:i:s');
break;
default:
return $obj->{'get' . $column->getPhpName()}();
}
}
开发者ID:bombayworks,项目名称:currycms,代码行数:23,代码来源:DatabaseHelper.php
注:本文中的ColumnMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论