本文整理汇总了PHP中Doctrine\DBAL\Platforms\AbstractPlatform类的典型用法代码示例。如果您正苦于以下问题:PHP AbstractPlatform类的具体用法?PHP AbstractPlatform怎么用?PHP AbstractPlatform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AbstractPlatform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validatePlatform
/**
* @param AbstractPlatform $platform
*
* @throws UnsupportedPlatformException
*/
protected function validatePlatform(AbstractPlatform $platform)
{
$platformName = $platform->getName();
if (isset($this->platforms) && !in_array($platformName, $this->platforms)) {
throw UnsupportedPlatformException::unsupportedPlatform($platformName);
}
}
示例2: getSQLDeclaration
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
if (!isset($fieldDeclaration['length'])) {
$fieldDeclaration['length'] = 32;
}
return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
}
示例3: convertToDatabaseValue
/**
* @param DateTimeOfDay $value
* @param AbstractPlatform $platform
*
* @return string
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if ($value instanceof DateTimeOfDay) {
return $value->toDateTime()->format($platform->getDateTimeFormatString());
}
return parent::convertToDatabaseValue($value, $platform);
}
示例4: processQueueCallback
/**
* ->processQueueCallback(function (\Dja\Db\Model\Metadata $metadata, \Doctrine\DBAL\Schema\Table $table, array $sql, \Doctrine\DBAL\Connection $db) {})
* @param callable|\Closure $callBack
*/
public function processQueueCallback(\Closure $callBack)
{
$callbackQueue = [];
while (count($this->generateQueue)) {
$modelName = array_shift($this->generateQueue);
try {
/** @var Metadata $metadata */
$metadata = $modelName::metadata();
$tblName = $metadata->getDbTableName();
if ($this->db->getSchemaManager()->tablesExist($tblName)) {
continue;
}
if (isset($this->generated[$tblName])) {
continue;
}
$table = $this->metadataToTable($metadata);
$this->generated[$tblName] = 1;
$sql = $this->dp->getCreateTableSQL($table, AbstractPlatform::CREATE_INDEXES);
array_unshift($callbackQueue, [$metadata, $table, $sql]);
$fks = $table->getForeignKeys();
if (count($fks)) {
$sql = [];
foreach ($fks as $fk) {
$sql[] = $this->dp->getCreateForeignKeySQL($fk, $table);
}
array_push($callbackQueue, [$metadata, $table, $sql]);
}
} catch (\Exception $e) {
pr($e->__toString());
}
}
foreach ($callbackQueue as $args) {
$callBack($args[0], $args[1], $args[2], $this->db);
}
}
示例5: getSqlDeclaration
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
$values = array_map(function ($val) {
return "'" . $val . "'";
}, $this->values);
return sprintf("ENUM(%s) COMMENT '%s'", implode(', ', $values), $platform->getDoctrineTypeComment($this));
}
示例6: convertToDatabaseValueSQL
/**
* @param string $sqlExpr
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
* @throws \Kdyby\Doctrine\NotImplementedException
* @return string
*/
public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform)
{
if (!$platform instanceof Doctrine\DBAL\Platforms\MySqlPlatform) {
throw new Kdyby\Doctrine\NotImplementedException("Unsupported platform " . $platform->getName());
}
return 'GeomFromText(' . $sqlExpr . ')';
}
示例7: 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();
}
示例8: convertToDatabaseValue
public function convertToDatabaseValue($timepoint, AbstractPlatform $platform)
{
if ($timepoint !== null) {
$dtime = $timepoint->asPHPDateTime();
return $dtime->format($platform->getDateTimeFormatString());
}
}
示例9: getSqlDeclaration
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
$fieldDeclaration['length'] = 255;
$fieldDeclaration['notnull'] = false;
$fieldDeclaration['default'] = null;
return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
}
示例10: setUp
protected function setUp()
{
// class has private constructor
$this->type = $this->getMockBuilder('Oro\\Bundle\\LocaleBundle\\DoctrineExtensions\\DBAL\\Types\\UTCTimeType')->setMethods(null)->disableOriginalConstructor()->getMock();
$this->platform = $this->getMockBuilder('Doctrine\\DBAL\\Platforms\\AbstractPlatform')->disableOriginalConstructor()->setMethods(array('getTimeFormatString'))->getMockForAbstractClass();
$this->platform->expects($this->any())->method('getTimeFormatString')->will($this->returnValue('H:i:s'));
}
示例11: getSQLDeclaration
/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
if ($platform->getName() === 'postgresql') {
return 'GEOMETRY';
}
return strtoupper($this->getName());
}
示例12: getSQLDeclaration
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
$fieldDeclaration['length'] = 25;
$fieldDeclaration['fixed'] = true;
$fieldDeclaration['notnull'] = true;
return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
}
示例13: getSQLDeclaration
/**
* {@inheritdoc}
* @param array $fieldDeclaration
* @param AbstractPlatform $platform
* @return
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
if (empty($fieldDeclaration['length'])) {
$fieldDeclaration['length'] = Path::MAX_LENGTH;
}
$type = $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
return $type;
}
示例14: convertToDatabaseValue
/** @noinspection PhpMissingParentCallCommonInspection
* @inheritdoc
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
/** @var DateTime|null $value */
if ($value === null) {
return null;
}
return $value->format($platform->getDateTimeFormatString());
}
示例15: convertToPHPValue
/** @noinspection PhpMissingParentCallCommonInspection
* @inheritdoc
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
/** @var string|null $value */
if ($value === null) {
return null;
}
return $this->convertDateTimeString($value, $platform->getDateTimeFormatString(), static::JSON_API_FORMAT);
}