本文整理汇总了PHP中Doctrine\DBAL\Types\Type类的典型用法代码示例。如果您正苦于以下问题:PHP Type类的具体用法?PHP Type怎么用?PHP Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Type类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setType
/**
* {@inheritdoc}
*/
public function setType(Type $type)
{
if ($this->constructed) {
$this->setOptions([OroOptions::KEY => [ExtendOptionsManager::TYPE_OPTION => $type->getName()]]);
}
return parent::setType($type);
}
开发者ID:xamin123,项目名称:platform,代码行数:10,代码来源:ExtendColumn.php
示例2: getTypeByDoctrineType
public static function getTypeByDoctrineType(Type $type)
{
$mapping = array_flip(self::$mapping);
if (isset($mapping[$type->getName()])) {
return $mapping[$type->getName()];
} else {
return TableInterface::TYPE_VARCHAR;
}
}
开发者ID:seytar,项目名称:psx,代码行数:9,代码来源:SerializeTrait.php
示例3: isCommentedDoctrineType
/**
* {@inheritdoc}
*/
public function isCommentedDoctrineType(Type $doctrineType)
{
if ($doctrineType->getName() === Type::BOOLEAN) {
// We require a commented boolean type in order to distinguish between boolean and smallint
// as both (have to) map to the same native type.
return true;
}
return parent::isCommentedDoctrineType($doctrineType);
}
开发者ID:doctrine,项目名称:dbal,代码行数:12,代码来源:DB2Platform.php
示例4: doctrineColumnLookup
public function doctrineColumnLookup($col_lookup)
{
if (isset($this->options['expr']) && isset($col_lookup[$this->options['expr']])) {
/**
* @var $col Column
*/
$col = $col_lookup[$this->options['expr']];
$this->type = $col->getType();
$this->typeName = self::simplifyTypeName($this->type->getName());
}
}
开发者ID:kevinmel2000,项目名称:crudkit,代码行数:11,代码来源:SQLColumn.php
示例5: changePrimaryKeyType
/**
* @param Schema $schema
* @param QueryBag $queries
* @param string $tableName
* @param string $columnName
* @param string $type
*
* @throws \Exception
*/
public function changePrimaryKeyType(Schema $schema, QueryBag $queries, $tableName, $columnName, $type)
{
$targetColumn = $schema->getTable($tableName)->getColumn($columnName);
$type = Type::getType($type);
if ($targetColumn->getType() === $type) {
return;
}
/** @var ForeignKeyConstraint[] $foreignKeys */
$foreignKeys = [];
foreach ($schema->getTables() as $table) {
/** @var ForeignKeyConstraint[] $tableForeignKeys */
$tableForeignKeys = array_filter($table->getForeignKeys(), function (ForeignKeyConstraint $tableForeignKey) use($tableName, $columnName) {
if ($tableForeignKey->getForeignTableName() !== $tableName) {
return false;
}
return $tableForeignKey->getForeignColumns() === [$columnName];
});
foreach ($tableForeignKeys as $tableForeignKey) {
$foreignKeys[$tableForeignKey->getName()] = $tableForeignKey;
$foreignKeyTableName = $tableForeignKey->getLocalTable()->getName();
$foreignKeyColumnNames = $tableForeignKey->getLocalColumns();
$queries->addPreQuery($this->platform->getDropForeignKeySQL($tableForeignKey, $foreignKeyTableName));
$column = $schema->getTable($foreignKeyTableName)->getColumn(reset($foreignKeyColumnNames));
if ($column instanceof ExtendColumn) {
$column->disableExtendOptions()->setType($type)->enableExtendOptions();
} else {
$column->setType($type);
}
}
}
$targetColumn->setType($type);
foreach ($foreignKeys as $foreignKey) {
$queries->addPostQuery($this->platform->getCreateForeignKeySQL($foreignKey, $foreignKey->getLocalTable()));
}
}
开发者ID:Maksold,项目名称:platform,代码行数:44,代码来源:ChangeTypeExtension.php
示例6: replaceImmutableTypes
/**
* Replaces default DateTime Doctrine types with their _immutable counterparts
*/
public static function replaceImmutableTypes()
{
Type::overrideType(Type::DATE, DateTimeImmutable\DateImmutableType::class);
Type::overrideType(Type::DATETIME, DateTimeImmutable\DateTimeImmutableType::class);
Type::overrideType(Type::DATETIMETZ, DateTimeImmutable\DateTimeTzImmutableType::class);
Type::overrideType(Type::TIME, DateTimeImmutable\TimeImmutableType::class);
}
开发者ID:Aurielle,项目名称:Nette-Doctrine-DateTimeImmutable-Types,代码行数:10,代码来源:TypeRegistrar.php
示例7: convertResultsInternal
protected function convertResultsInternal($results, AbstractPlatform $platform, CaseSensor $sensor)
{
if (is_array($results)) {
$results = current($results);
}
return Type::getType($this->type)->convertToPHPValue($results, $platform);
}
开发者ID:ritalin,项目名称:omelet,代码行数:7,代码来源:BuiltinDomain.php
示例8: _getPortableTableColumnDefinition
/**
* {@inheritdoc}
*/
protected function _getPortableTableColumnDefinition($tableColumn)
{
$tableColumn = array_change_key_case($tableColumn, \CASE_LOWER);
$length = null;
$fixed = null;
$unsigned = false;
$scale = false;
$precision = false;
$type = $this->_platform->getDoctrineTypeMapping($tableColumn['typename']);
switch (strtolower($tableColumn['typename'])) {
case 'varchar':
$length = $tableColumn['length'];
$fixed = false;
break;
case 'character':
$length = $tableColumn['length'];
$fixed = true;
break;
case 'clob':
$length = $tableColumn['length'];
break;
case 'decimal':
case 'double':
case 'real':
$scale = $tableColumn['scale'];
$precision = $tableColumn['length'];
break;
}
$options = array('length' => $length, 'unsigned' => (bool) $unsigned, 'fixed' => (bool) $fixed, 'default' => $tableColumn['default'] == "NULL" ? null : $tableColumn['default'], 'notnull' => (bool) ($tableColumn['nulls'] == 'N'), 'scale' => null, 'precision' => null, 'platformOptions' => array());
if ($scale !== null && $precision !== null) {
$options['scale'] = $scale;
$options['precision'] = $precision;
}
return new Column($tableColumn['colname'], \Doctrine\DBAL\Types\Type::getType($type), $options);
}
开发者ID:RuntyCybin,项目名称:csymfony,代码行数:38,代码来源:DB2SchemaManager.php
示例9: buildForm
public function buildForm(FormBuilderInterface $builder, array $options)
{
$schemaManager = $this->container['db']->getSchemaManager();
foreach ($schemaManager->listTableColumns($this->table) as $column) {
// here we try to display nicely database relations w/ foreign keys
if (false !== strpos($column->getName(), '_id')) {
$table = str_replace('_id', '', $column->getName());
$dataMap = new DataMap($this->container['db'], $schemaManager);
$choices = $dataMap->mapForeignKeys($table, $column);
if (is_array($choices)) {
$column->setType(Type::getType('array'));
}
}
switch ($column->getType()) {
case 'Integer':
$builder->add($column->getName(), 'integer', array('read_only' => $column->getName() === 'id' ? true : false, 'required' => $column->getNotNull()));
break;
case 'Array':
$builder->add($column->getName(), 'choice', array('choices' => $choices, 'required' => $column->getNotNull()));
break;
case 'Boolean':
$builder->add($column->getName(), 'checkbox', array('required' => false));
break;
case 'String':
$builder->add($column->getName(), 'text', array('required' => $column->getNotNull()));
break;
case 'Text':
$builder->add($column->getName(), 'textarea', array('required' => $column->getNotNull()));
break;
}
}
}
开发者ID:wisembly,项目名称:silexcms,代码行数:32,代码来源:RowType.php
示例10: setUp
protected function setUp()
{
parent::setUp();
DDC2494TinyIntType::$calls = array();
Type::addType('ddc2494_tinyint', __NAMESPACE__ . '\\DDC2494TinyIntType');
$this->_schemaTool->createSchema(array($this->_em->getClassMetadata(DDC2494Currency::CLASSNAME), $this->_em->getClassMetadata(DDC2494Campaign::CLASSNAME)));
}
开发者ID:pnaq57,项目名称:zf2demo,代码行数:7,代码来源:DDC2494Test.php
示例11: setUp
protected function setUp()
{
parent::setUp();
Type::addType(DDC2012TsVectorType::MYTYPE, __NAMESPACE__ . '\\DDC2012TsVectorType');
DDC2012TsVectorType::$calls = array();
$this->_schemaTool->createSchema(array($this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC2012Item'), $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC2012ItemPerson')));
}
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:7,代码来源:DDC2012Test.php
示例12: createService
/**
* Create service
*
* @param ServiceLocatorInterface $validators
* @return mixed
*/
public function createService(ServiceLocatorInterface $validators)
{
if (isset($this->options['enum'])) {
$this->options['enum'] = DoctrineType::getType($this->options['enum']);
}
return new EnumValidator($this->options);
}
开发者ID:bvoronov,项目名称:zb-utils,代码行数:13,代码来源:EnumValidatorFactory.php
示例13: boot
public function boot()
{
if (!Type::hasType('branch_logo')) {
Type::addType('branch_logo', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\BranchLogoType');
}
if (!Type::hasType('priority')) {
Type::addType('priority', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketPriorityType');
}
if (!Type::hasType('file')) {
Type::addType('file', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\AttachmentFileType');
}
if (!Type::hasType('status')) {
Type::addType('status', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketStatusType');
}
if (!Type::hasType('source')) {
Type::addType('source', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketSourceType');
}
if (!Type::hasType('ticket_sequence_number')) {
Type::addType('ticket_sequence_number', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketSequenceNumberType');
}
if (!Type::hasType('ticket_unique_id')) {
Type::addType('ticket_unique_id', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketUniqueIdType');
}
foreach ($this->dataAuditTypes as $type) {
if (!AuditFieldTypeRegistry::hasType($type)) {
AuditFieldTypeRegistry::addType($type, $type);
}
}
$em = $this->container->get('doctrine.orm.default_entity_manager');
$conn = $em->getConnection();
$conn->getDatabasePlatform()->registerDoctrineTypeMapping('FILE', 'string');
}
开发者ID:northdakota,项目名称:diamantedesk-application,代码行数:32,代码来源:DiamanteDeskBundle.php
示例14: getEntityManager
public static function getEntityManager($smart = FALSE, $path_to_entity = null, $proxyPath = null, $proxyNamespace = null)
{
if (empty(self::$em)) {
if ($path_to_entity === NULL) {
//$path_to_entity = PATH_ROOT . '/' . Sokol::getApp()->name . '/Entity';
$path_to_entity = PATH_ROOT . '/Entity';
}
$isDev = Sokol::getApp()->isDev;
$connectionParams = Sokol::getConfig('db');
//---Table Prefix---
$tablePrefix = !empty($connectionParams['tablePrefix']) ? $connectionParams['tablePrefix'] : null;
if ($tablePrefix) {
$evm = new EventManager();
$tablePrefix = new TablePrefix($tablePrefix);
$evm->addEventListener(Events::loadClassMetadata, $tablePrefix);
}
//---/Table Prefix---
if ($smart) {
self::$em = self::getEmSmart($path_to_entity, $isDev, $connectionParams, $evm);
} else {
if ($proxyPath === NULL) {
$proxyPath = PATH_ROOT . '/' . Sokol::getApp()->name . '/Proxy';
}
if ($proxyNamespace === NULL) {
$proxyNamespace = Sokol::getApp()->getNamespace() . '\\Proxy';
}
self::$em = self::getEm($path_to_entity, $isDev, $connectionParams, $evm, $proxyPath, $proxyNamespace);
}
//подключаем тип данных "html"
Type::addType('html', 'Sokol\\Doctrine\\Extension\\HtmlType');
self::$em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('db_html', 'html');
}
return self::$em;
}
开发者ID:php-nik,项目名称:sokol,代码行数:34,代码来源:Doctrine.php
示例15: loadClassMetadata
/**
* Adds doctrine point type
*
* @param LoadClassMetadataEventArgs $eventArgs
*/
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
{
$classMetadata = $eventArgs->getClassMetadata();
if (null === $classMetadata->reflClass) {
return;
}
if ($this->isGeocodable($classMetadata)) {
if (!Type::hasType('point')) {
Type::addType('point', 'Knp\\DoctrineBehaviors\\DBAL\\Types\\PointType');
}
$em = $eventArgs->getEntityManager();
$con = $em->getConnection();
// skip non-postgres platforms
if (!$con->getDatabasePlatform() instanceof PostgreSqlPlatform && !$con->getDatabasePlatform() instanceof MySqlPlatform) {
return;
}
// skip platforms with registerd stuff
if (!$con->getDatabasePlatform()->hasDoctrineTypeMappingFor('point')) {
$con->getDatabasePlatform()->registerDoctrineTypeMapping('point', 'point');
if ($con->getDatabasePlatform() instanceof PostgreSqlPlatform) {
$em->getConfiguration()->addCustomNumericFunction('DISTANCE', 'Knp\\DoctrineBehaviors\\ORM\\Geocodable\\Query\\AST\\Functions\\DistanceFunction');
}
}
$classMetadata->mapField(['fieldName' => 'location', 'type' => 'point', 'nullable' => true]);
}
}
开发者ID:adampiotrowski,项目名称:DoctrineBehaviors,代码行数:31,代码来源:GeocodableSubscriber.php
示例16: __construct
public function __construct(Connection $con)
{
$this->con = $con;
$this->platform = $con->getDatabasePlatform();
$this->phpType = Type::getType(PhpTypeType::NAME);
$this->insertStmt = $con->prepare(self::INSERT_SQL);
}
开发者ID:walkeralencar,项目名称:ci-php-analyzer,代码行数:7,代码来源:ArgumentPersister.php
示例17: boot
/**
* Boots the bundle
*
* @return void
*/
public function boot()
{
if ($this->container->has('doctrine')) {
Type::addType(MbStringType::TYPE_NAME, MbStringType::class);
Type::addType(StdStringType::TYPE_NAME, StdStringType::class);
Type::addType(DateTimeType::TYPE_NAME, DateTimeType::class);
Type::addType(DateType::TYPE_NAME, DateType::class);
Type::addType(TimeType::TYPE_NAME, TimeType::class);
Type::addType(TimezoneType::TYPE_NAME, TimezoneType::class);
Type::addType(UuidType::TYPE_NAME, UuidType::class);
Type::addType(CurrencyType::TYPE_NAME, CurrencyType::class);
Type::addType(MoneyType::TYPE_NAME, MoneyType::class);
Type::addType(UriType::TYPE_NAME, UriType::class);
Type::addType(UrlType::TYPE_NAME, UrlType::class);
/** @var EntityManager $entityManager */
$entityManager = $this->container->get('doctrine')->getManager();
/** @var AbstractPlatform $platform */
$platform = $entityManager->getConnection()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('db_' . MbStringType::TYPE_NAME, MbStringType::TYPE_NAME);
$platform->registerDoctrineTypeMapping('db_' . StdStringType::TYPE_NAME, StdStringType::TYPE_NAME);
$platform->registerDoctrineTypeMapping('db_' . DateTimeType::TYPE_NAME, DateTimeType::TYPE_NAME);
$platform->registerDoctrineTypeMapping('db_' . DateType::TYPE_NAME, DateType::TYPE_NAME);
$platform->registerDoctrineTypeMapping('db_' . TimeType::TYPE_NAME, TimeType::TYPE_NAME);
$platform->registerDoctrineTypeMapping('db_' . TimezoneType::TYPE_NAME, TimezoneType::TYPE_NAME);
$platform->registerDoctrineTypeMapping('db_' . UuidType::TYPE_NAME, UuidType::TYPE_NAME);
$platform->registerDoctrineTypeMapping('db_' . CurrencyType::TYPE_NAME, CurrencyType::TYPE_NAME);
$platform->registerDoctrineTypeMapping('db_' . MoneyType::TYPE_NAME, MoneyType::TYPE_NAME);
$platform->registerDoctrineTypeMapping('db_' . UriType::TYPE_NAME, UriType::TYPE_NAME);
$platform->registerDoctrineTypeMapping('db_' . UrlType::TYPE_NAME, UrlType::TYPE_NAME);
}
}
开发者ID:novuso,项目名称:common-bundle,代码行数:36,代码来源:NovusoCommonBundle.php
示例18: setUp
protected function setUp()
{
$this->platform = $this->getMockBuilder('Doctrine\\DBAL\\Platforms\\AbstractPlatform')->setMethods(array('getVarcharTypeDeclarationSQL'))->getMockForAbstractClass();
$this->platform->expects($this->any())->method('getVarcharTypeDeclarationSQL')->will($this->returnValue('DUMMYVARCHAR()'));
$this->type = Type::getType('phone_number');
$this->phoneNumberUtil = PhoneNumberUtil::getInstance();
}
开发者ID:skafandri,项目名称:phone-number-bundle,代码行数:7,代码来源:PhoneNumberTypeTest.php
示例19: __construct
public function __construct($setConfigFiles = true)
{
if ($setConfigFiles) {
$this->configFile = __DIR__ . '/../../../config.php';
$this->localConfigFile = __DIR__ . '/../../../config.local.php';
}
parent::__construct();
$isDevMode = false;
$cache = new \Doctrine\Common\Cache\FilesystemCache(__DIR__ . '/../../tmp');
$config = Setup::createConfiguration($isDevMode, __DIR__ . '/../../tmp', $cache);
$config->setProxyDir(__DIR__ . '/../../tmp');
$config->setProxyNamespace('MyProject\\Proxies');
$config->setAutoGenerateProxyClasses(true);
$paths = [__DIR__ . '/../Entity'];
$driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver(new AnnotationReader(), $paths);
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists');
$config->setMetadataDriverImpl($driver);
//$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
$conn = ['driver' => 'mysqli', 'host' => '127.0.0.1', 'user' => $this->databaseFactory->getUserName(), 'password' => $this->databaseFactory->getPassword(), 'dbname' => $this->databaseFactory->getDatabaseName()];
$this->entityManager = EntityManager::create($conn, $config);
$this->entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
\Doctrine\DBAL\Types\Type::addType('enum', StringType::class);
$this->entityManager->getConfiguration()->addCustomStringFunction('DATE', DateFunction::class);
$this->user = $this->entityManager->createQueryBuilder()->select('u')->from(Sources\Tests\Entity\User::class, 'u');
}
开发者ID:mesour,项目名称:filter,代码行数:25,代码来源:BaseDoctrineFilterSourceTest.php
示例20: _getPortableTableColumnDefinition
/**
* @param array $column
*
* @return Column
*/
protected function _getPortableTableColumnDefinition($column)
{
$type = $this->orient2Doctrine[$column['type']];
$type = $this->_platform->getDoctrineTypeMapping($type);
$options = array('default' => isset($column['defaultValue']) ? $column['defaultValue'] : null, 'notnull' => isset($column['notNull']) ? $column['notNull'] : null, 'collate' => isset($column['collate']) ? $column['collate'] : null, 'length' => null, 'unsigned' => false, 'fixed' => false, 'scale' => null, 'precision' => null, 'autoincrement' => false, 'comment' => null);
return new Column($column['name'], Type::getType($type), $options);
}
开发者ID:mihai-stancu,项目名称:orientdb-orm,代码行数:12,代码来源:OrientDBSchemaManager.php
注:本文中的Doctrine\DBAL\Types\Type类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论