1<?php 2 3namespace Doctrine\DBAL\Platforms; 4 5use Doctrine\DBAL\Schema\Index; 6use Doctrine\DBAL\Schema\Sequence; 7 8/** 9 * The SQLAnywhere12Platform provides the behavior, features and SQL dialect of the 10 * SAP Sybase SQL Anywhere 12 database platform. 11 */ 12class SQLAnywhere12Platform extends SQLAnywhere11Platform 13{ 14 /** 15 * {@inheritdoc} 16 */ 17 public function getCreateSequenceSQL(Sequence $sequence) 18 { 19 return 'CREATE SEQUENCE ' . $sequence->getQuotedName($this) . 20 ' INCREMENT BY ' . $sequence->getAllocationSize() . 21 ' START WITH ' . $sequence->getInitialValue() . 22 ' MINVALUE ' . $sequence->getInitialValue(); 23 } 24 25 /** 26 * {@inheritdoc} 27 */ 28 public function getAlterSequenceSQL(Sequence $sequence) 29 { 30 return 'ALTER SEQUENCE ' . $sequence->getQuotedName($this) . 31 ' INCREMENT BY ' . $sequence->getAllocationSize(); 32 } 33 34 /** 35 * {@inheritdoc} 36 */ 37 public function getDateTimeTzFormatString() 38 { 39 return 'Y-m-d H:i:s.uP'; 40 } 41 42 /** 43 * {@inheritdoc} 44 */ 45 public function getDateTimeTzTypeDeclarationSQL(array $column) 46 { 47 return 'TIMESTAMP WITH TIME ZONE'; 48 } 49 50 /** 51 * {@inheritdoc} 52 */ 53 public function getDropSequenceSQL($sequence) 54 { 55 if ($sequence instanceof Sequence) { 56 $sequence = $sequence->getQuotedName($this); 57 } 58 59 return 'DROP SEQUENCE ' . $sequence; 60 } 61 62 /** 63 * {@inheritdoc} 64 */ 65 public function getListSequencesSQL($database) 66 { 67 return 'SELECT sequence_name, increment_by, start_with, min_value FROM SYS.SYSSEQUENCE'; 68 } 69 70 /** 71 * {@inheritdoc} 72 */ 73 public function getSequenceNextValSQL($sequence) 74 { 75 return 'SELECT ' . $sequence . '.NEXTVAL'; 76 } 77 78 /** 79 * {@inheritdoc} 80 */ 81 public function supportsSequences() 82 { 83 return true; 84 } 85 86 /** 87 * {@inheritdoc} 88 */ 89 protected function getAdvancedIndexOptionsSQL(Index $index) 90 { 91 if (! $index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_not_distinct')) { 92 return ' WITH NULLS NOT DISTINCT' . parent::getAdvancedIndexOptionsSQL($index); 93 } 94 95 return parent::getAdvancedIndexOptionsSQL($index); 96 } 97 98 /** 99 * {@inheritdoc} 100 */ 101 protected function getReservedKeywordsClass() 102 { 103 return Keywords\SQLAnywhere12Keywords::class; 104 } 105 106 /** 107 * {@inheritDoc} 108 */ 109 protected function initializeDoctrineTypeMappings() 110 { 111 parent::initializeDoctrineTypeMappings(); 112 $this->doctrineTypeMapping['timestamp with time zone'] = 'datetime'; 113 } 114} 115