當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AbstractPlatform::getSubstringExpression方法代碼示例

本文整理匯總了PHP中Doctrine\DBAL\Platforms\AbstractPlatform::getSubstringExpression方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractPlatform::getSubstringExpression方法的具體用法?PHP AbstractPlatform::getSubstringExpression怎麽用?PHP AbstractPlatform::getSubstringExpression使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\DBAL\Platforms\AbstractPlatform的用法示例。


在下文中一共展示了AbstractPlatform::getSubstringExpression方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: up

 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     // fill createdAt and updatedAt
     $queries->addPreQuery(new ParametrizedSqlMigrationQuery('UPDATE oro_calendar_event SET created_at = :date, updated_at = :date', ['date' => new \DateTime('now', new \DateTimeZone('UTC'))], ['date' => Type::DATETIME]));
     // copy title to description if needed
     $queries->addPreQuery(new ParametrizedSqlMigrationQuery(sprintf('UPDATE oro_calendar_event SET description = title WHERE %s > 255 OR title LIKE :new_line', $this->platform->getLengthExpression('title')), ['new_line' => '%\\n%'], ['new_line' => Type::STRING]));
     // trim title
     $locateExpr = $this->platform->getLocateExpression('title', ':lf');
     $queries->addPreQuery(new ParametrizedSqlMigrationQuery(sprintf('UPDATE oro_calendar_event SET title = %s WHERE %s > 0', $this->platform->getSubstringExpression(sprintf('REPLACE(%s, :cr, :empty)', $this->platform->getSubstringExpression('title', 1, $locateExpr)), 1, 255), $locateExpr), ['lf' => '\\n', 'cr' => '\\r', 'empty' => ''], ['lf' => Type::STRING, 'cr' => Type::STRING, 'empty' => Type::STRING]));
     $queries->addPreQuery(sprintf('UPDATE oro_calendar_event SET title = %s WHERE %s > 255', $this->platform->getSubstringExpression('title', 1, 255), $this->platform->getLengthExpression('title')));
     $table = $schema->getTable('oro_calendar_event');
     $table->getColumn('title')->setType(Type::getType(Type::STRING))->setOptions(['length' => 255]);
     $table->getColumn('created_at')->setOptions(['notnull' => true]);
     $table->getColumn('updated_at')->setOptions(['notnull' => true]);
     $this->enableDataAudit($table);
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:19,代碼來源:OroCalendarBundle.php

示例2: subString

 /**
  * Returns part of a string.
  *
  * Note: Not SQL92, but common functionality.
  *
  * @param string $value the target $value the string or the string column.
  * @param int $from extract from this characeter.
  * @param int $len extract this amount of characters.
  *
  * @return string sql that extracts part of a string.
  */
 public function subString($value, $from, $len = null)
 {
     return $this->platform->getSubstringExpression($value, $from, $len);
 }
開發者ID:ezsystems,項目名稱:ezpublish-kernel,代碼行數:15,代碼來源:DoctrineExpression.php


注:本文中的Doctrine\DBAL\Platforms\AbstractPlatform::getSubstringExpression方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。