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


PHP Connection\ConnectionInterface类代码示例

本文整理汇总了PHP中Propel\Runtime\Connection\ConnectionInterface的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionInterface类的具体用法?PHP ConnectionInterface怎么用?PHP ConnectionInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: postActivation

 public function postActivation(ConnectionInterface $con = null)
 {
     $database = new Database($con->getWrappedConnection());
     $database->insertSql(null, [__DIR__ . '/Config/thelia.sql']);
     // Add order-invoice.before-discount hook if not already defined
     if (null === HookQuery::create()->findOneByCode('order-invoice.before-discount')) {
         try {
             $hookEvent = new HookCreateEvent();
             $hookEvent->setCode('order-invoice.before-discount')->setType(TemplateDefinition::FRONT_OFFICE)->setNative(false)->setActive(true)->setLocale('en_US')->setTitle("Before discount code form block");
             $this->getDispatcher()->dispatch(TheliaEvents::HOOK_CREATE, $hookEvent);
             if ($hookEvent->hasHook()) {
                 // Assign module to this hook
                 $moduleHookEvent = new ModuleHookCreateEvent();
                 $moduleHookEvent->setModuleId($this->getModuleId())->setHookId($hookEvent->getHook()->getId())->setClassname('creditaccount.order_invoice.hook')->setMethod('orderInvoiceForm');
                 // Activate module hook
                 $this->getDispatcher()->dispatch(TheliaEvents::MODULE_HOOK_CREATE, $moduleHookEvent);
                 if ($moduleHookEvent->hasModuleHook()) {
                     $event = new ModuleHookToggleActivationEvent($moduleHookEvent->getModuleHook());
                     $this->getDispatcher()->dispatch(TheliaEvents::MODULE_HOOK_TOGGLE_ACTIVATION, $event);
                 }
             }
         } catch (\Exception $ex) {
             throw new TheliaProcessException(Translator::getInstance()->trans("Failed to put module in 'order-invoice.before-discount' hook (%err)", ['%err' => $ex->getMessage()]), $ex);
         }
     }
 }
开发者ID:gillesbourgeat,项目名称:CreditAccount,代码行数:26,代码来源:CreditAccount.php

示例2: getWriteConnection

 /**
  * @param \Propel\Runtime\Adapter\AdapterInterface $adapter
  *
  * @return \Propel\Runtime\Connection\ConnectionInterface
  */
 public function getWriteConnection(AdapterInterface $adapter = null)
 {
     if (null === $this->connection) {
         $this->connection = ConnectionFactory::create($this->configuration, $adapter);
         $this->connection->setName($this->getName());
     }
     return $this->connection;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:13,代码来源:ConnectionManagerSingle.php

示例3: postActivation

 public function postActivation(ConnectionInterface $con = null)
 {
     try {
         OrderCommentQuery::create()->findOne();
     } catch (\Exception $e) {
         $database = new Database($con->getWrappedConnection());
         $database->insertSql(null, array(THELIA_ROOT . '/local/modules/OrderComment/Config/thelia.sql'));
     }
 }
开发者ID:InformatiqueProg,项目名称:OrderComment,代码行数:9,代码来源:OrderComment.php

示例4: getId

 /**
  * Gets ID for specified sequence name.
  *
  * @param     ConnectionInterface $con
  * @param     string  $name
  *
  * @return    integer
  */
 public function getId(ConnectionInterface $con, $name = null)
 {
     if ($name === null) {
         throw new InvalidArgumentException("Unable to fetch next sequence ID without sequence name.");
     }
     $stmt = $con->query("SELECT nextval(" . $con->quote($name) . ")");
     $row = $stmt->fetch(PDO::FETCH_NUM);
     return $row[0];
 }
开发者ID:rozwell,项目名称:Propel2,代码行数:17,代码来源:PgsqlAdapter.php

示例5: initConnection

 public function initConnection(ConnectionInterface $con, array $settings)
 {
     $con->query('PRAGMA foreign_keys = ON');
     parent::initConnection($con, $settings);
     //add regex support
     $con->sqliteCreateFunction('regexp', function ($pattern, $value) {
         mb_regex_encoding('UTF-8');
         return false !== mb_ereg($pattern, $value) ? 1 : 0;
     });
 }
开发者ID:bondarovich,项目名称:Propel2,代码行数:10,代码来源:SqliteAdapter.php

示例6: postActivation

 public function postActivation(ConnectionInterface $con = null)
 {
     $database = new Database($con->getWrappedConnection());
     // Insert email message
     $database->insertSql(null, array(__DIR__ . "/Config/setup.sql"));
     /* insert the images from image folder if not already done */
     $moduleModel = $this->getModuleModel();
     if (!$moduleModel->isModuleImageDeployed($con)) {
         $this->deployImageFolder($moduleModel, sprintf('%s/images', __DIR__), $con);
     }
 }
开发者ID:badelas,项目名称:thelia,代码行数:11,代码来源:Cheque.php

示例7: delete

 public function delete(ConnectionInterface $con = null)
 {
     $con->beginTransaction();
     try {
         TestableAggregateCommentQuery::create()->filterByPrimaryKey($this->getPrimaryKey())->delete($con);
         $con->commit();
         $this->setDeleted(true);
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
开发者ID:disider,项目名称:Propel2,代码行数:12,代码来源:AggregateColumnsBehaviorTestClasses.php

示例8: setCharset

 /**
  * @see       parent::setCharset()
  *
  * @param     PDO     $con
  * @param     string  $charset
  *
  * @throws    PropelException
  */
 public function setCharset(ConnectionInterface $con, $charset)
 {
     switch (strtolower($charset)) {
         case 'utf-8':
             $con->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_UTF8);
             break;
         case 'system':
             $con->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_SYSTEM);
             break;
         default:
             throw new PropelException('only utf-8 or system encoding are supported by the pdo_sqlsrv driver');
     }
 }
开发者ID:norfil,项目名称:Propel2,代码行数:21,代码来源:SqlsrvAdapter.php

示例9: executeStatements

 /**
  * Execute a list of DDL statements based on an array
  * Does not use transactions since they are not supported in DDL statements
  *
  * @param array               $statements a list of SQL statements
  * @param ConnectionInterface $connection a connection object
  *
  * @return integer the number of executed statements
  */
 protected static function executeStatements($statements, ConnectionInterface $connection)
 {
     $executed = 0;
     foreach ($statements as $statement) {
         $stmt = $connection->prepare($statement);
         if ($stmt instanceof StatementInterface) {
             // only execute if has no error
             $stmt->execute();
             $executed++;
         }
     }
     return $executed;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:22,代码来源:SqlParser.php

示例10: updateAncestorsTree

 /**
  * Update all ancestor entries to reflect changes on this instance.
  *
  * @param ConnectionInterface $con
  *
  * @return \Propel\Bundle\PropelBundle\Model\Acl\ObjectIdentity $this
  */
 protected function updateAncestorsTree(ConnectionInterface $con = null)
 {
     $con->beginTransaction();
     $oldAncestors = ObjectIdentityQuery::create()->findAncestors($this, $con);
     $children = ObjectIdentityQuery::create()->findGrandChildren($this, $con);
     $children->append($this);
     if (count($oldAncestors)) {
         foreach ($children as $eachChild) {
             /*
              * Delete only those entries, that are ancestors based on the parent relation.
              * Ancestors of grand children up to the current node will be kept.
              */
             $query = ObjectIdentityAncestorQuery::create()->filterByObjectIdentityId($eachChild->getId())->filterByObjectIdentityRelatedByAncestorId($oldAncestors, Criteria::IN);
             if ($eachChild->getId() !== $this->getId()) {
                 $query->filterByAncestorId(array($eachChild->getId(), $this->getId()), Criteria::NOT_IN);
             } else {
                 $query->filterByAncestorId($this->getId(), Criteria::NOT_EQUAL);
             }
             $query->delete($con);
         }
     }
     // This is the new parent object identity!
     $parent = $this->getObjectIdentityRelatedByParentObjectIdentityId($con);
     if (null !== $parent) {
         $newAncestors = ObjectIdentityQuery::create()->findAncestors($parent, $con);
         $newAncestors->append($parent);
         foreach ($newAncestors as $eachAncestor) {
             // This collection contains the current object identity!
             foreach ($children as $eachChild) {
                 $ancestor = ObjectIdentityAncestorQuery::create()->filterByObjectIdentityId($eachChild->getId())->filterByAncestorId($eachAncestor->getId())->findOneOrCreate($con);
                 // If the entry already exists, next please.
                 if (!$ancestor->isNew()) {
                     continue;
                 }
                 if ($eachChild->getId() === $this->getId()) {
                     // Do not save() here, as it would result in an infinite recursion loop!
                     $this->addObjectIdentityAncestorRelatedByObjectIdentityId($ancestor);
                 } else {
                     // Save the new ancestor to avoid integrity constraint violation.
                     $ancestor->save($con);
                     $eachChild->addObjectIdentityAncestorRelatedByObjectIdentityId($ancestor)->save($con);
                 }
             }
         }
     }
     $con->commit();
     return $this;
 }
开发者ID:naldz,项目名称:cyberden,代码行数:55,代码来源:ObjectIdentity.php

示例11: __construct

 /**
  * @param ConnectionInterface $connection Propel connection
  */
 public function __construct(ConnectionInterface $connection, array $logMethods = array('beginTransaction', 'commit', 'rollBack', 'forceRollBack', 'exec', 'query', 'execute'))
 {
     if ($connection instanceof ProfilerConnectionWrapper) {
         $connection->setLogMethods($logMethods);
         $this->config = $connection->getProfiler()->getConfiguration();
         $this->handler = new TestHandler();
         if ($connection->getLogger() instanceof Logger) {
             $this->logger = $connection->getLogger();
             $this->logger->pushHandler($this->handler);
         } else {
             $this->errors[] = 'Supported only monolog logger';
         }
     } else {
         $this->errors[] = 'You need set ProfilerConnectionWrapper';
     }
 }
开发者ID:clee03,项目名称:metal,代码行数:19,代码来源:Propel2Collector.php

示例12: postActivation

 /**
  * @param ConnectionInterface $con
  */
 public function postActivation(ConnectionInterface $con = null)
 {
     $database = new Database($con->getWrappedConnection());
     $database->insertSql(null, [__DIR__ . DS . 'Config' . DS . 'thelia.sql']);
     $languages = LangQuery::create()->find();
     if (null === MessageQuery::create()->findOneByName(self::MESSAGE_SEND_CONFIRMATION)) {
         $message = new Message();
         $message->setName(self::MESSAGE_SEND_CONFIRMATION)->setHtmlLayoutFileName('')->setHtmlTemplateFileName(self::MESSAGE_SEND_CONFIRMATION . '.html')->setTextLayoutFileName('')->setTextTemplateFileName(self::MESSAGE_SEND_CONFIRMATION . '.txt');
         foreach ($languages as $language) {
             /** @var Lang $language */
             $locale = $language->getLocale();
             $message->setLocale($locale);
             $message->setTitle($this->trans('Order send confirmation', $locale));
             $message->setSubject($this->trans('Order send confirmation', $locale));
         }
         $message->save();
     }
 }
开发者ID:Asenar,项目名称:thelia-FreeShipping,代码行数:21,代码来源:FreeShipping.php

示例13: applyXml

 /**
  * @param string $xml
  *
  * @return Database|boolean
  */
 public function applyXml($xml, $changeRequired = false)
 {
     $this->readDatabase();
     $builder = new QuickBuilder();
     $builder->setIdentifierQuoting(true);
     $builder->setPlatform($this->database->getPlatform());
     $builder->setSchema($xml);
     $database = $builder->getDatabase();
     $database->setSchema('migration');
     $database->setPlatform($this->database->getPlatform());
     $diff = DatabaseComparator::computeDiff($this->database, $database);
     if (false === $diff) {
         if ($changeRequired) {
             throw new BuildException(sprintf("No changes in schema to current database: \nSchema database:\n%s\n\nCurrent Database:\n%s", $database, $this->database));
         }
         return false;
     }
     $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff);
     $this->con->beginTransaction();
     if (!$sql) {
         throw new BuildException(sprintf('Ooops. There is a diff between current database and schema xml but no SQL has been generated. Change: %s', $diff));
     }
     $statements = SqlParser::parseString($sql);
     foreach ($statements as $statement) {
         try {
             $stmt = $this->con->prepare($statement);
             $stmt->execute();
         } catch (\Exception $e) {
             throw new BuildException(sprintf("Can not execute SQL: \n%s\nFrom database: \n%s\n\nTo database: \n%s\n", $statement, $this->database, $database), null, $e);
         }
     }
     $this->con->commit();
     return $database;
 }
开发者ID:disider,项目名称:Propel2,代码行数:39,代码来源:MigrationTestCase.php

示例14: applyXml

 /**
  * @param string $xml
  *
  * @return Database
  */
 public function applyXml($xml)
 {
     $this->readDatabase();
     $builder = new QuickBuilder();
     $builder->setPlatform($this->database->getPlatform());
     $builder->setSchema($xml);
     $database = $builder->getDatabase();
     $database->setSchema('migration');
     $database->setPlatform($this->database->getPlatform());
     $diff = DatabaseComparator::computeDiff($this->database, $database);
     if (false === $diff) {
         return null;
     }
     $sql = $this->database->getPlatform()->getModifyDatabaseDDL($diff);
     $this->con->beginTransaction();
     $statements = SqlParser::parseString($sql);
     foreach ($statements as $statement) {
         try {
             $stmt = $this->con->prepare($statement);
             $stmt->execute();
         } catch (\Exception $e) {
             $this->con->rollBack();
             throw new BuildException(sprintf("Can not execute SQL: \n%s\nFrom database: \n%s\n\nTo database: \n%s\n", $statement, $this->database, $database), null, $e);
         }
     }
     $this->con->commit();
     return $database;
 }
开发者ID:a-melnichuk,项目名称:Movies-Demo,代码行数:33,代码来源:MigrationTestCase.php

示例15: updateBlocksAssignedToDeletedCategoryNode

 /**
  * @param int $idCategoryNode
  *
  * @return void
  */
 public function updateBlocksAssignedToDeletedCategoryNode($idCategoryNode)
 {
     $this->connection->beginTransaction();
     $assignedBlocks = $this->getCmsBlocksByIdCategoryNode($idCategoryNode);
     foreach ($assignedBlocks as $idBlock => $blockTransfer) {
         //unique keys is on name, type and value therefore the name has to be changed
         $blockTransfer->setName($blockTransfer->getName() . '_' . CmsConstants::RESOURCE_TYPE_CATEGORY_NODE . '_deleted_' . $blockTransfer->getIdCmsBlock());
         $blockTransfer->setType(CmsConstants::RESOURCE_TYPE_STATIC);
         $blockTransfer->setValue(0);
         $this->saveBlockAndTouch($blockTransfer);
     }
     $this->connection->commit();
 }
开发者ID:spryker,项目名称:Cms,代码行数:18,代码来源:BlockManager.php


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