本文整理汇总了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);
}
示例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);
}