当前位置: 首页>>代码示例>>PHP>>正文


PHP QueryBag::addPreQuery方法代码示例

本文整理汇总了PHP中Oro\Bundle\MigrationBundle\Migration\QueryBag::addPreQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBag::addPreQuery方法的具体用法?PHP QueryBag::addPreQuery怎么用?PHP QueryBag::addPreQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Oro\Bundle\MigrationBundle\Migration\QueryBag的用法示例。


在下文中一共展示了QueryBag::addPreQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testBag

 public function testBag()
 {
     $queries = new QueryBag();
     $queries->addPreQuery('query1');
     $queries->addPreQuery('query2');
     $queries->addPostQuery('query3');
     $queries->addQuery('query4');
     $this->assertEquals(['query1', 'query2'], $queries->getPreQueries());
     $this->assertEquals(['query3', 'query4'], $queries->getPostQueries());
     $queries->clear();
     $this->assertCount(0, $queries->getPreQueries());
     $this->assertCount(0, $queries->getPostQueries());
 }
开发者ID:Maksold,项目名称:platform,代码行数:13,代码来源:QueryBagTest.php

示例2: up

 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     /** Update Email Origin Name */
     $queries->addPreQuery(new ParametrizedSqlMigrationQuery('UPDATE oro_email_origin SET name = :new_name WHERE name = :old_name', ['new_name' => 'useremailorigin', 'old_name' => 'imapemailorigin'], ['new_name' => Type::STRING, 'old_name' => Type::STRING]));
     /** Tables generation **/
     self::addSmtpFieldsToOroEmailOriginTable($schema);
 }
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:OroImapBundle.php

示例3: up

 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $queries->addPreQuery(new ParametrizedSqlMigrationQuery('UPDATE orocrm_call SET created_at = :date, updated_at = :date', ['date' => new \DateTime('now', new \DateTimeZone('UTC'))], ['date' => Type::DATETIME]));
     $table = $schema->getTable('orocrm_call');
     $table->getColumn('created_at')->setOptions(['notnull' => true]);
     $table->getColumn('updated_at')->setOptions(['notnull' => true]);
 }
开发者ID:antrampa,项目名称:crm,代码行数:10,代码来源:OroCRMCallBundle.php

示例4: 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

示例5: 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

示例6: up

 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     // fill empty updatedAt of orocrm_case_comment
     $queries->addPreQuery('UPDATE orocrm_case_comment SET updatedAt = createdAt WHERE updatedAt IS NULL');
     // make updatedAt NOT NULL
     $table = $schema->getTable('orocrm_case_comment');
     $table->changeColumn('updatedAt', ['notnull' => true]);
 }
开发者ID:antrampa,项目名称:crm,代码行数:11,代码来源:OroCRMCaseBundle.php

示例7: up

 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     // copy user's IMAP email origins to new table
     $queries->addPreQuery('INSERT INTO oro_user_email_origin (user_id, origin_id) ' . 'SELECT id, imap_configuration_id FROM oro_user WHERE imap_configuration_id IS NOT NULL');
     // drop old FK for IMAP email origins
     $table = $schema->getTable('oro_user');
     $table->dropIndex('UNIQ_F82840BC678BF607');
     $table->removeForeignKey('FK_F82840BC678BF607');
     $table->dropColumn('imap_configuration_id');
 }
开发者ID:ramunasd,项目名称:platform,代码行数:13,代码来源:DropUserImapConfigurationId.php

示例8: up

 /**
  * @inheritdoc
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $queries->addPreQuery($this->getRemoveObsoleteValuesSql());
     $table = $schema->getTable('oro_entity_config_value');
     $table->dropColumn('serializable');
     $table->getColumn('value')->setType(Type::getType(Type::STRING));
     $table->addIndex(['scope', 'code', 'value', 'entity_id'], 'idx_entity_config_index_entity');
     $table->addIndex(['scope', 'code', 'value', 'field_id'], 'idx_entity_config_index_field');
     $this->renameExtension->renameTable($schema, $queries, 'oro_entity_config_value', 'oro_entity_config_index_value');
 }
开发者ID:xamin123,项目名称:platform,代码行数:13,代码来源:CreateIndexedConfigValues.php

示例9: up

 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     // Copy values from VAT to temp auxiliary column with correction
     $query = 'UPDATE orocrm_magento_customer ' . 'SET vat_temp = ROUND(vat * 100.0) ' . 'WHERE vat IS NOT NULL';
     $queries->addPreQuery($query);
     // Change data type of the VAT column
     $schema->getTable('orocrm_magento_customer')->getColumn('vat')->setType(Type::getType(Type::STRING));
     // Copy values back to VAT column
     $query = 'UPDATE orocrm_magento_customer ' . 'SET vat = vat_temp ' . 'WHERE vat IS NOT NULL';
     $queries->addPostQuery($query);
 }
开发者ID:antrampa,项目名称:crm,代码行数:14,代码来源:OroCRMMagentoBundle.php

示例10: up

 /**
  * @inheritdoc
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $table = $schema->getTable('oro_windows_state');
     $column = $table->getColumn('data');
     if ($this->platform instanceof PostgreSqlPlatform) {
         $queries->addPreQuery('ALTER TABLE oro_windows_state ALTER COLUMN data TYPE JSON USING data::JSON');
     } else {
         $column->setType(Type::getType(Type::JSON_ARRAY));
     }
     $column->setOptions(['comment' => '(DC2Type:json_array)']);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:14,代码来源:OroWindowsBundle.php

示例11: up

 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     // update data in accordance with new column requirement
     $queries->addPreQuery(sprintf("UPDATE oro_email SET message_id = CONCAT('id.', REPLACE(%s, '-',''), '%s') WHERE message_id IS NULL", $this->platform->getGuidExpression(), '@bap.migration.generated'));
     self::oroEmailToFolderRelationTable($schema);
     // make message_id not null & add index
     $table = $schema->getTable('oro_email');
     $table->changeColumn('message_id', ['notnull' => true]);
     $table->addIndex(['message_id'], 'IDX_email_message_id', []);
     // migrate existing email-folder relations
     $queries->addPostQuery("INSERT INTO oro_email_to_folder (email_id, emailfolder_id) SELECT id, folder_id FROM oro_email");
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:OroEmailBundle.php

示例12: up

 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $queries->addPreQuery($this->getFillAccountActivityQuery());
     $queries->addPreQuery($this->getFillContactActivityQuery());
     // fill empty updatedAt of orocrm_task
     $queries->addPreQuery('UPDATE orocrm_task SET updatedAt = createdAt WHERE updatedAt IS NULL');
     $taskTable = $schema->getTable('orocrm_task');
     $this->enableDataAudit($taskTable);
     // relation with account
     $taskTable->removeForeignKey('FK_814DEE3F11A6570A');
     $taskTable->dropColumn('related_account_id');
     $queries->addPostQuery($this->getDropEntityConfigManyToOneRelationQuery('relatedAccount'));
     // relation with contact
     $taskTable->removeForeignKey('FK_814DEE3F6D6C2DFA');
     $taskTable->dropColumn('related_contact_id');
     $queries->addPostQuery($this->getDropEntityConfigManyToOneRelationQuery('relatedContact'));
     // reporter
     $taskTable->removeForeignKey('fk_orocrm_task_reporter_id');
     $taskTable->dropColumn('reporter_id');
     $queries->addPostQuery($this->getDropEntityConfigManyToOneRelationQuery('reporter'));
     // make updatedAt NOT NULL
     $taskTable->getColumn('updatedAt')->setOptions(['notnull' => true]);
 }
开发者ID:antrampa,项目名称:crm,代码行数:26,代码来源:OroCRMTaskBundle.php

示例13: up

 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     $queries->addPreQuery(new UpdateEmailUserQuery());
 }
开发者ID:Maksold,项目名称:platform,代码行数:7,代码来源:UpdateEmailUserData.php

示例14: up

 /**
  * {@inheritdoc}
  */
 public function up(Schema $schema, QueryBag $queries)
 {
     if ($this->container->hasParameter('installed') && $this->container->getParameter('installed')) {
         $queries->addPreQuery(new UpdateActivityButtonConfigQuery());
     }
 }
开发者ID:ramunasd,项目名称:platform,代码行数:9,代码来源:OroActivityBundleInstaller.php

示例15: fillActivityListTables

 /**
  * @param QueryBag $queries
  */
 protected function fillActivityListTables(QueryBag $queries)
 {
     // Fill activitylists tables
     $queries->addPreQuery(new ParametrizedSqlMigrationQuery($this->getFillCartEmailActivityListQuery(), ['class' => 'Oro\\Bundle\\EmailBundle\\Entity\\Email'], ['class' => Type::STRING]));
     $queries->addPreQuery(new ParametrizedSqlMigrationQuery($this->getFillCartCallActivityListQuery(), ['class' => 'OroCRM\\Bundle\\CallBundle\\Entity\\Call'], ['class' => Type::STRING]));
     $queries->addPreQuery(new ParametrizedSqlMigrationQuery($this->getFillOrderEmailActivityListQuery(), ['class' => 'Oro\\Bundle\\EmailBundle\\Entity\\Email'], ['class' => Type::STRING]));
     $queries->addPreQuery(new ParametrizedSqlMigrationQuery($this->getFillOrderCallActivityListQuery(), ['class' => 'OroCRM\\Bundle\\CallBundle\\Entity\\Call'], ['class' => Type::STRING]));
 }
开发者ID:antrampa,项目名称:crm,代码行数:11,代码来源:FillActivityAssociationTables.php


注:本文中的Oro\Bundle\MigrationBundle\Migration\QueryBag::addPreQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。