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


PHP Runtime\Propel类代码示例

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


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

示例1: setUp

    protected function setUp()
    {
        parent::setUp();
        if (!class_exists('Propel\\Bundle\\PropelBundle\\Tests\\Fixtures\\DataFixtures\\Loader\\CoolBook')) {
            $schema = <<<XML
<database name="default" package="vendor.bundles.Propel.Bundle.PropelBundle.Tests.Fixtures.DataFixtures.Loader" namespace="Propel\\Bundle\\PropelBundle\\Tests\\Fixtures\\DataFixtures\\Loader" defaultIdMethod="native">
    <table name="cool_book">
        <column name="id" type="integer" primaryKey="true" />
        <column name="name" type="varchar" size="255" />
        <column name="description" type="varchar" />
        <column name="author_id" type="integer" required="false" defaultValue="null" />
        <column name="complementary_infos" required="false" type="object" description="An object column" />

        <foreign-key foreignTable="cool_book_author" onDelete="CASCADE" onUpdate="CASCADE">
            <reference local="author_id" foreign="id" />
        </foreign-key>
    </table>

    <table name="cool_book_author">
        <column name="id" type="integer" primaryKey="true" />
        <column name="name" type="varchar" size="255" />
    </table>
</database>
XML;
            QuickBuilder::buildSchema($schema);
        }
        $this->con = Propel::getServiceContainer()->getConnection('default');
        $this->con->beginTransaction();
    }
开发者ID:naldz,项目名称:cyberden,代码行数:29,代码来源:TestCase.php

示例2: __construct

 public function __construct(LoggerInterface $alternativeLogger = null)
 {
     $con = Propel::getServiceContainer()->getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
     $con->setLogger($this);
     $con->setLogMethods(array('exec', 'query', 'execute', 'beginTransaction', 'commit', 'rollBack'));
     $this->alternativeLogger = $alternativeLogger;
 }
开发者ID:alex63530,项目名称:thelia,代码行数:7,代码来源:PropelCollector.php

示例3: delete

 public function delete(FolderDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     if (null !== ($folder = FolderQuery::create()->findPk($event->getFolderId()))) {
         $con = Propel::getWriteConnection(FolderTableMap::DATABASE_NAME);
         $con->beginTransaction();
         try {
             $fileList = ['images' => [], 'documentList' => []];
             // Get folder's files to delete after folder deletion
             $fileList['images']['list'] = FolderImageQuery::create()->findByFolderId($event->getFolderId());
             $fileList['images']['type'] = TheliaEvents::IMAGE_DELETE;
             $fileList['documentList']['list'] = FolderDocumentQuery::create()->findByFolderId($event->getFolderId());
             $fileList['documentList']['type'] = TheliaEvents::DOCUMENT_DELETE;
             // Delete folder
             $folder->setDispatcher($dispatcher)->delete($con);
             $event->setFolder($folder);
             // Dispatch delete folder's files event
             foreach ($fileList as $fileTypeList) {
                 foreach ($fileTypeList['list'] as $fileToDelete) {
                     $fileDeleteEvent = new FileDeleteEvent($fileToDelete);
                     $dispatcher->dispatch($fileTypeList['type'], $fileDeleteEvent);
                 }
             }
             $con->commit();
         } catch (\Exception $e) {
             $con->rollback();
             throw $e;
         }
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:29,代码来源:Folder.php

示例4: register

 /**
  * {@inheritDoc}
  */
 public function register(Container $container)
 {
     // Append custom settings with missing params from default settings
     $container['settings']['database'] = self::mergeWithDefaultSettings($container['settings']['database']);
     $settings = $container['settings']['database'];
     $logLevel = $settings['logger']['level'] ?? null;
     $logPath = $settings['logger']['path'] ?? null;
     $className = $settings['classname'] ?? null;
     if (!$className) {
         $className = 'Propel\\Runtime\\Connection\\ConnectionWrapper';
         if ($logLevel == Logger::DEBUG) {
             $className = 'Propel\\Runtime\\Connection\\ProfilerConnectionWrapper';
         }
     }
     $manager = new ConnectionManagerSingle();
     $manager->setConfiguration(['classname' => $className, 'dsn' => $settings['dsn'], 'user' => $settings['user'], 'password' => $settings['password'], 'settings' => $settings['settings']]);
     $manager->setName($settings['connection']);
     /** @var StandardServiceContainer $serviceContainer */
     $serviceContainer = Propel::getServiceContainer();
     $serviceContainer->checkVersion($settings['version']);
     $serviceContainer->setAdapterClass($settings['connection'], $settings['adapter']);
     $serviceContainer->setConnectionManager($settings['connection'], $manager);
     $serviceContainer->setDefaultDatasource($settings['connection']);
     if ($logPath && $logLevel) {
         $logger = new Logger('defaultLogger');
         $logger->pushHandler(new StreamHandler($logPath, $logLevel));
         $serviceContainer->setLogger('defaultLogger', $logger);
         if ($logLevel == Logger::DEBUG) {
             /** @var ConnectionWrapper $con */
             $con = Propel::getConnection();
             $con->useDebug(true);
         }
     }
 }
开发者ID:ansas,项目名称:php-component,代码行数:37,代码来源:PropelProvider.php

示例5: __construct

 public function __construct()
 {
     $this->helper = new Helper();
     $this->debug = Propel::getWriteConnection(\Map\JaCategoriasTableMap::DATABASE_NAME);
     $this->debug->setLogMethods(array('exec', 'query', 'execute', 'beginTransaction', 'commit', 'rollBack', 'bindValue'));
     $this->debug->useDebug(Config::$DEBUG_SQL);
 }
开发者ID:alejandrososa,项目名称:angularja,代码行数:7,代码来源:JaCategorias.php

示例6: process

 public function process()
 {
     $logger = Tlog::getInstance();
     $logger->setLevel(Tlog::DEBUG);
     $updatedVersions = array();
     $currentVersion = ConfigQuery::read('thelia_version');
     $logger->debug("start update process");
     if (true === $this->isLatestVersion($currentVersion)) {
         $logger->debug("You already have the latest version. No update available");
         throw new UpToDateException('You already have the latest version. No update available');
     }
     $index = array_search($currentVersion, self::$version);
     $con = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::DATABASE_NAME);
     $con->beginTransaction();
     $logger->debug("begin transaction");
     $database = new Database($con->getWrappedConnection());
     try {
         $size = count(self::$version);
         for ($i = ++$index; $i < $size; $i++) {
             $this->updateToVersion(self::$version[$i], $database, $logger);
             $updatedVersions[] = self::$version[$i];
         }
         $con->commit();
         $logger->debug('update successfully');
     } catch (PropelException $e) {
         $con->rollBack();
         $logger->error(sprintf('error during update process with message : %s', $e->getMessage()));
         throw $e;
     }
     $logger->debug('end of update processing');
     return $updatedVersions;
 }
开发者ID:alex63530,项目名称:thelia,代码行数:32,代码来源:Update.php

示例7: deleteCard

 /**
  * @param Click $card
  */
 public function deleteCard($card)
 {
     $delete = "\n        DELETE FROM logintime t1\n   JOIN\n    (\n     SELECT MAX(datetime)\n      AS max_dt\n      FROM logintime\n      WHERE user_id = 1\n    ) t2\nWHERE t1.datetime  = t2.max_dt\n   AND card = {$card->get}\n   ";
     $con = Propel::getConnection();
     $stmt = $con->prepare($delete);
     return $stmt->execute();
 }
开发者ID:bassix,项目名称:FreakXoHBingo,代码行数:10,代码来源:ClicksManager.php

示例8: processLenderInvite

 function processLenderInvite(Lender $invitee, InviteVisit $lenderInviteVisit)
 {
     $con = Propel::getWriteConnection(TransactionTableMap::DATABASE_NAME);
     for ($retry = 0; $retry < 3; $retry++) {
         $con->beginTransaction();
         try {
             $invite = $lenderInviteVisit->getInvite();
             if ($invite) {
                 $res1 = $invite->setInvitee($invitee)->save();
             } else {
                 $invite = new Invite();
                 $invite->setLender($lenderInviteVisit->getLender());
                 $invite->setEmail($invitee->getUser()->getEmail());
                 $invite->setInvitee($invitee);
                 $invite->setInvited(false);
                 $res1 = $invitee->save($con);
             }
             if (!$res1) {
                 throw new \Exception();
             }
             $this->transactionService->addLenderInviteTransaction($con, $invite);
         } catch (\Exception $e) {
             $con->rollback();
         }
         $con->commit();
         //TODO , invite_notify(see below commented if statement)
         //   if ($lender['invite_notify']) {
         $this->lenderMailer->sendLenderInviteCredit($invite);
         // }
         $this->mixpanelService->trackInviteAccept($invite);
         return $invite;
     }
     return false;
 }
开发者ID:Junyue,项目名称:zidisha2,代码行数:34,代码来源:LenderService.php

示例9: execute

 public function execute($params)
 {
     $id = $params['id'];
     $movie = \Engine\MovieQuery::create()->findPK($id);
     $movie->setTitle($params['title']);
     $movie->setYear($params['year']);
     $movie->setFormat($params['format']);
     $actors = [];
     //generate array of new actors
     foreach ($params['actor_name'] as $key => $name) {
         $actor = new \Engine\Actor();
         $actor->setMovieId($id);
         $actor->setName($name);
         $actor->setSurname($params['actor_surname'][$key]);
         $actors[] = $actor;
     }
     //propel accepts a collection to set related data
     $collection = new \Propel\Runtime\Collection\ObjectCollection($actors);
     $con = \Propel\Runtime\Propel::getWriteConnection(\Engine\Map\MovieTableMap::DATABASE_NAME);
     $con->beginTransaction();
     try {
         //set collection of actors; this automatically deletes old related actors
         $movie->setActors($collection);
         $movie->save($con);
         $con->commit();
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
     return ['Message' => 'Movie has beed updated successfully.', 'Status' => 1];
 }
开发者ID:a-melnichuk,项目名称:Movies-Demo,代码行数:31,代码来源:Update.php

示例10: createOrUpdate

 protected function createOrUpdate(PopInCampaignEvent $event, PopInCampaign $model)
 {
     $con = Propel::getConnection(PopInCampaignTableMap::DATABASE_NAME);
     $con->beginTransaction();
     try {
         if (null !== ($id = $event->getId())) {
             $model->setId($id);
         }
         if (null !== ($start = $event->getStart())) {
             $model->setStart($start);
         }
         if (null !== ($end = $event->getEnd())) {
             $model->setEnd($end);
         }
         if (null !== ($contentSourceType = $event->getContentSourceType())) {
             $model->setContentSourceType($contentSourceType);
         }
         if (null !== ($contentSourceId = $event->getContentSourceId())) {
             $model->setContentSourceId($contentSourceId);
         }
         $model->save($con);
         $con->commit();
     } catch (\Exception $e) {
         $con->rollback();
         throw $e;
     }
     $event->setPopInCampaign($model);
 }
开发者ID:bcbrr,项目名称:PopIn,代码行数:28,代码来源:PopInCampaignAction.php

示例11: registerRuntimeConfiguration

 /**
  * Register propel runtime configuration.
  *
  * @return void
  */
 protected function registerRuntimeConfiguration()
 {
     $propel_conf = $this->app->config['propel.propel'];
     if (!isset($propel_conf['runtime']['connections'])) {
         throw new \InvalidArgumentException('Unable to guess Propel runtime config file. Please, initialize the "propel.runtime" parameter.');
     }
     /** @var $serviceContainer \Propel\Runtime\ServiceContainer\StandardServiceContainer */
     $serviceContainer = Propel::getServiceContainer();
     $serviceContainer->closeConnections();
     $serviceContainer->checkVersion('2.0.0-dev');
     $runtime_conf = $propel_conf['runtime'];
     // set connections
     foreach ($runtime_conf['connections'] as $connection_name) {
         $config = $propel_conf['database']['connections'][$connection_name];
         $serviceContainer->setAdapterClass($connection_name, $config['adapter']);
         $manager = new ConnectionManagerSingle();
         $manager->setConfiguration($config + [$propel_conf['paths']]);
         $manager->setName($connection_name);
         $serviceContainer->setConnectionManager($connection_name, $manager);
     }
     $serviceContainer->setDefaultDatasource($runtime_conf['defaultConnection']);
     // set loggers
     $has_default_logger = false;
     if (isset($runtime_conf['log'])) {
         $has_default_logger = array_key_exists('defaultLogger', $runtime_conf['log']);
         foreach ($runtime_conf['log'] as $logger_name => $logger_conf) {
             $serviceContainer->setLoggerConfiguration($logger_name, $logger_conf);
         }
     }
     if (!$has_default_logger) {
         $serviceContainer->setLogger('defaultLogger', \Log::getMonolog());
     }
     Propel::setServiceContainer($serviceContainer);
 }
开发者ID:julienvincent,项目名称:PropelLaravel,代码行数:39,代码来源:RuntimeServiceProvider.php

示例12: delete

 /**
  * Delete a category entry
  *
  * @param \Thelia\Core\Event\Category\CategoryDeleteEvent $event
  */
 public function delete(CategoryDeleteEvent $event)
 {
     if (null !== ($category = CategoryQuery::create()->findPk($event->getCategoryId()))) {
         $con = Propel::getWriteConnection(CategoryTableMap::DATABASE_NAME);
         $con->beginTransaction();
         try {
             // Get category's files to delete after category deletion
             $fileList['images']['list'] = CategoryImageQuery::create()->findByCategoryId($event->getCategoryId());
             $fileList['images']['type'] = TheliaEvents::IMAGE_DELETE;
             $fileList['documentList']['list'] = CategoryDocumentQuery::create()->findByCategoryId($event->getCategoryId());
             $fileList['documentList']['type'] = TheliaEvents::DOCUMENT_DELETE;
             // Delete category
             $category->setDispatcher($event->getDispatcher())->delete($con);
             $event->setCategory($category);
             // Dispatch delete category's files event
             foreach ($fileList as $fileTypeList) {
                 foreach ($fileTypeList['list'] as $fileToDelete) {
                     $fileDeleteEvent = new FileDeleteEvent($fileToDelete);
                     $event->getDispatcher()->dispatch($fileTypeList['type'], $fileDeleteEvent);
                 }
             }
             $con->commit();
         } catch (\Exception $e) {
             $con->rollback();
             throw $e;
         }
     }
 }
开发者ID:margery,项目名称:thelia,代码行数:33,代码来源:Category.php

示例13: install

 /**
  */
 public function install()
 {
     // install sql
     $files = ['sql/keeko.sql', 'data/static-data.sql', 'data/dummy-data.sql'];
     try {
         $repo = $this->getServiceContainer()->getResourceRepository();
         $con = Propel::getConnection();
         foreach ($files as $file) {
             if ($repo->contains('/iuf/junia/database/' . $file)) {
                 $sql = $repo->get('/iuf/junia/database/' . $file)->getBody();
                 $stmt = $con->prepare($sql);
                 $stmt->execute();
             }
         }
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
     // install static data
     // 		$comp = new Competition();
     // 		$comp->setLabel('Individual Freestyle');
     // 		$comp->save();
     // 		$comp = new Competition();
     // 		$comp->setLabel('Pairs Freestyle');
     // 		$comp->save();
     // 		$comp = new Competition();
     // 		$comp->setLabel('Small Group Freestyle');
     // 		$comp->save();
     // 		$comp = new Competition();
     // 		$comp->setLabel('Large Group Freestyle');
     // 		$comp->save();
 }
开发者ID:iuf,项目名称:junia,代码行数:33,代码来源:JuniaModule.php

示例14: testComputeWithSchema

 public function testComputeWithSchema()
 {
     $con = Propel::getServiceContainer()->getConnection(BookstoreTableMap::DATABASE_NAME);
     BookstoreContestEntryQuery::create()->deleteAll();
     BookstoreQuery::create()->deleteAll();
     CustomerQuery::create()->deleteAll();
     BookstoreContestQuery::create()->deleteAll();
     $store = new Bookstore();
     $store->setStoreName('FreeAgent Bookstore');
     $store->save();
     $this->assertEquals(0, $store->computeTotalContestEntries($con), 'The compute method returns 0 for objects with no related objects');
     $contest = new BookstoreContest();
     $contest->setBookstore($store);
     $contest->save();
     $customer1 = new Customer();
     $customer1->save();
     $entry1 = new BookstoreContestEntry();
     $entry1->setBookstore($store);
     $entry1->setBookstoreContest($contest);
     $entry1->setCustomer($customer1);
     $entry1->save(null, true);
     // skip reload to avoid #1151 for now
     $this->assertEquals(1, $store->computeTotalContestEntries($con), 'The compute method computes the aggregate function on related objects');
     $customer2 = new Customer();
     $customer2->save();
     $entry2 = new BookstoreContestEntry();
     $entry2->setBookstore($store);
     $entry2->setBookstoreContest($contest);
     $entry2->setCustomer($customer2);
     $entry2->save(null, true);
     // skip reload to avoid #1151 for now
     $this->assertEquals(2, $store->computeTotalContestEntries($con), 'The compute method computes the aggregate function on related objects');
     $entry1->delete();
     $this->assertEquals(1, $store->computeTotalContestEntries($con), 'The compute method computes the aggregate function on related objects');
 }
开发者ID:disider,项目名称:Propel2,代码行数:35,代码来源:AggregateColumnBehaviorWithSchemaTest.php

示例15: updateOrCreateLinkAction

 public function updateOrCreateLinkAction($id)
 {
     // Check current user authorization
     if (null !== ($response = $this->checkAuth(AdminResources::MODULE, DealerTeam::getModuleCode(), AccessManager::CREATE))) {
         return $response;
     }
     $retour = [];
     $code = 200;
     $con = Propel::getConnection();
     $con->beginTransaction();
     try {
         $data = ['id' => $id];
         $tempOption = $this->getRequest()->request->get("option_id");
         $dafyDealer = [];
         foreach ($tempOption as $option) {
             $data["dealer_option_id"] = $option;
             $temp = $this->getService()->createFromArray($data);
             if ($temp) {
                 $dafyDealer[] = $temp->toArray();
             }
         }
         $con->commit();
         $retour["data"] = $dafyDealer;
     } catch (\Exception $e) {
         $con->rollBack();
         // Any other error
         Tlog::getInstance()->addError($e->getMessage());
         $code = $e->getCode();
         if ($code == 0) {
             $code = 500;
         }
         $retour["message"] = $e->getMessage();
     }
     return JsonResponse::create($retour, $code);
 }
开发者ID:thelia-modules,项目名称:DealerTeam,代码行数:35,代码来源:DealerTeamController.php


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