本文整理汇总了PHP中Magento\Framework\DB\Adapter\AdapterInterface::dropTrigger方法的典型用法代码示例。如果您正苦于以下问题:PHP AdapterInterface::dropTrigger方法的具体用法?PHP AdapterInterface::dropTrigger怎么用?PHP AdapterInterface::dropTrigger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\DB\Adapter\AdapterInterface
的用法示例。
在下文中一共展示了AdapterInterface::dropTrigger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createDelta
/**
* Create delta for specified table
*
* @param string $documentName
* @param string $deltaLogName
* @param string $idKey
* @return void
*/
public function createDelta($documentName, $deltaLogName, $idKey)
{
if (!$this->resourceAdapter->isTableExists($deltaLogName)) {
$triggerTable = $this->resourceAdapter->newTable($deltaLogName)->addColumn($idKey, \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, ['nullable' => false, 'primary' => true])->addColumn('operation', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT)->addColumn('processed', \Magento\Framework\DB\Ddl\Table::TYPE_BOOLEAN, null, ['nullable' => false, 'default' => 0]);
$this->resourceAdapter->createTable($triggerTable);
} else {
$this->deleteAllRecords($deltaLogName);
}
foreach (Trigger::getListOfEvents() as $event) {
$triggerName = $this->resourceAdapter->getTableName('trg_' . $documentName . '_after_' . strtolower($event));
$statement = $this->buildStatement($event, $idKey, $deltaLogName);
$trigger = $this->triggerFactory->create()->setTime(Trigger::TIME_AFTER)->setEvent($event)->setTable($documentName);
$triggerKey = $documentName . $event . Trigger::TIME_AFTER;
$triggerExists = $this->isTriggerExist($triggerKey);
if ($triggerExists) {
$triggerName = $this->triggers[$triggerKey]['trigger_name'];
$oldTriggerStatement = $this->triggers[$triggerKey]['action_statement'];
if (strpos($oldTriggerStatement, $statement) !== false) {
unset($trigger);
continue;
}
$trigger->addStatement($oldTriggerStatement);
$this->resourceAdapter->dropTrigger($triggerName);
}
$trigger->addStatement($statement)->setName($triggerName);
$this->resourceAdapter->createTrigger($trigger);
if (!$triggerExists) {
$this->triggers[$triggerKey] = 1;
}
unset($trigger);
}
}
示例2: remove
/**
* Remove subscription
*
* @return \Magento\Framework\Mview\View\SubscriptionInterface
*/
public function remove()
{
foreach (Trigger::getListOfEvents() as $event) {
$triggerName = $this->getAfterEventTriggerName($event);
/** @var Trigger $trigger */
$trigger = $this->triggerFactory->create()->setName($triggerName)->setTime(Trigger::TIME_AFTER)->setEvent($event)->setTable($this->resource->getTableName($this->getTableName()));
// Add statements for linked views
foreach ($this->getLinkedViews() as $view) {
/** @var \Magento\Framework\Mview\ViewInterface $view */
$trigger->addStatement($this->buildStatement($event, $view->getChangelog()));
}
$this->connection->dropTrigger($trigger->getName());
// Re-create trigger if trigger used by linked views
if ($trigger->getStatements()) {
$this->connection->createTrigger($trigger);
}
}
return $this;
}