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


PHP Propel::getConnection方法代码示例

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


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

示例1: setup

 function setup()
 {
     global $CC_CONFIG;
     $con = Propel::getConnection();
     // Clear the files table
     $sql = "DELETE FROM " . $CC_CONFIG["filesTable"];
     $con->exec($sql);
     // Add a file
     $values = array("filepath" => dirname(__FILE__) . "/test10001.mp3");
     $this->storedFile = Application_Model_StoredFile::Insert($values, false);
     // Add a file
     $values = array("filepath" => dirname(__FILE__) . "/test10002.mp3");
     $this->storedFile2 = Application_Model_StoredFile::Insert($values, false);
     // Clear the schedule table
     $sql = "DELETE FROM " . $CC_CONFIG["scheduleTable"];
     $con->exec($sql);
     // Create a playlist
     $playlist = new Application_Model_Playlist();
     $playlist->create("Scheduler Unit Test");
     $result = $playlist->addAudioClip($this->storedFile->getId());
     $result = $playlist->addAudioClip($this->storedFile2->getId());
     $result = $playlist->addAudioClip($this->storedFile2->getId());
     // Schedule it
     $i = new Application_Model_ScheduleGroup();
     $this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:26,代码来源:SchedulerExportTests.php

示例2: doUpdateAllModerations

 public static function doUpdateAllModerations($selectCriteria, $values, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     return BasePeer::doUpdate($selectCriteria, $values, $con);
 }
开发者ID:DBezemer,项目名称:server,代码行数:7,代码来源:moderationPeer.php

示例3: getPopularTags

 public static function getPopularTags($max = 30)
 {
     $connection = Propel::getConnection();
     $query = 'SELECT %s as query, COUNT(*) as count
           FROM %s
           INNER JOIN %s ON %s = %s
           INNER JOIN %s ON %s = %s
           WHERE %s = %s
           GROUP BY query
           ORDER BY count DESC';
     $query = sprintf($query, QueryPeer::QUERY, QueryPeer::TABLE_NAME, ReportQueryPeer::TABLE_NAME, QueryPeer::ID, ReportQueryPeer::QUERY_ID, ReportPeer::TABLE_NAME, ReportQueryPeer::REPORT_ID, ReportPeer::ID, ReportPeer::PUBLIC_RECORD, true);
     $statement = $connection->prepareStatement($query);
     $statement->setLimit($max);
     $resultset = $statement->executeQuery();
     $tags = array();
     $max_count = 0;
     while ($resultset->next()) {
         if (!$max_count) {
             $max_count = $resultset->getInt('count');
         }
         $queries[] = array('query' => $resultset->getString('query'), 'rank' => floor($resultset->getInt('count') / $max_count * 9 + 1), 'count' => $resultset->getInt('count'));
     }
     ksort($queries);
     return $queries;
 }
开发者ID:hoydaa,项目名称:googlevolume.com,代码行数:25,代码来源:QueryPeer.php

示例4: update

 /**
  * Update the application delay registry
  * @param array $aData
  * @return string
  **/
 public function update($aData)
 {
     $oConnection = Propel::getConnection(AppDelayPeer::DATABASE_NAME);
     try {
         $oAppDelay = AppDelayPeer::retrieveByPK($aData['APP_DELAY_UID']);
         if (!is_null($oAppDelay)) {
             $oAppDelay->fromArray($aData, BasePeer::TYPE_FIELDNAME);
             if ($oAppDelay->validate()) {
                 $oConnection->begin();
                 $iResult = $oAppDelay->save();
                 $oConnection->commit();
                 return $iResult;
             } else {
                 $sMessage = '';
                 $aValidationFailures = $oAppDelay->getValidationFailures();
                 foreach ($aValidationFailures as $oValidationFailure) {
                     $sMessage .= $oValidationFailure->getMessage() . '<br />';
                 }
                 throw new Exception('The registry cannot be updated!<br />' . $sMessage);
             }
         } else {
             throw new Exception('This row doesn\'t exist!');
         }
     } catch (Exception $oError) {
         $oConnection->rollback();
         throw $oError;
     }
 }
开发者ID:emildev35,项目名称:processmaker,代码行数:33,代码来源:AppDelay.php

示例5: executeSidebar

 public function executeSidebar(sfWebRequest $request)
 {
     $route = sfContext::getInstance()->getRouting()->getCurrentRouteName();
     $this->route = $route;
     $id = $request->getParameter('catalogId');
     $stm = Propel::getConnection()->prepare('
         SELECT title,id FROM category WHERE parent_id=4
     ');
     $stm->execute();
     $menu = $stm->fetchAll(PDO::FETCH_OBJ);
     $this->menu = $menu;
     $stm = Propel::getConnection()->prepare('
         SELECT
             title,id
         FROM
             category_has_product
         INNER JOIN product ON product.id = category_has_product.product_id
         WHERE
             category_has_product.category_id = :id
     ');
     $stm->bindParam(':id', $id);
     $stm->execute();
     $product = $stm->fetchAll(PDO::FETCH_OBJ);
     $this->product = $product;
 }
开发者ID:alexspark21,项目名称:symfony_bisM,代码行数:25,代码来源:components.class.php

示例6: abortDbBatchJob

 public static function abortDbBatchJob(BatchJob $dbBatchJob, $force = false)
 {
     // No need to abort finished job
     if (in_array($dbBatchJob->getStatus(), BatchJobPeer::getClosedStatusList())) {
         if ($force) {
             $dbBatchJob->setExecutionStatus(BatchJobExecutionStatus::ABORTED);
             $dbBatchJob->save();
         }
         return $dbBatchJob;
     }
     $lockObject = $dbBatchJob->getBatchJobLock();
     if (is_null($lockObject)) {
         KalturaLog::err("Batch job [" . $dbBatchJob->getId() . "] doesn't have a lock object and can't be deleted. Status (" . $dbBatchJob->getStatus() . ")");
         return $dbBatchJob;
     }
     // Update status
     $con = Propel::getConnection();
     $update = new Criteria();
     $update->add(BatchJobLockPeer::STATUS, BatchJob::BATCHJOB_STATUS_ABORTED);
     $update->add(BatchJobLockPeer::VERSION, $lockObject->getVersion() + 1);
     $updateCondition = new Criteria();
     $updateCondition->add(BatchJobLockPeer::ID, $lockObject->getId(), Criteria::EQUAL);
     $updateCondition->add(BatchJobLockPeer::VERSION, $lockObject->getVersion(), Criteria::EQUAL);
     $updateCondition->add(BatchJobLockPeer::SCHEDULER_ID, null, Criteria::ISNULL);
     $affectedRows = BasePeer::doUpdate($updateCondition, $update, $con);
     if ($affectedRows) {
         $dbBatchJob->setExecutionStatus(BatchJobExecutionStatus::ABORTED);
         $dbBatchJob = self::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_ABORTED);
     } else {
         $dbBatchJob->setExecutionStatus(BatchJobExecutionStatus::ABORTED);
         $dbBatchJob->save();
     }
     self::abortChildJobs($dbBatchJob);
     return $dbBatchJob;
 }
开发者ID:ace3535,项目名称:server,代码行数:35,代码来源:kJobsManager.php

示例7: setDefaultRelatedElements

 /**
  * Inserts the menu links related to the inserted content,
  * into the w3sMenuElements table
  *   
  * @return bool
  * 
  */
 protected function setDefaultRelatedElements()
 {
     $bRollBack = false;
     $con = Propel::getConnection();
     $con = w3sPropelWorkaround::beginTransaction($con);
     for ($i = 1; $i < 4; $i++) {
         $newMenu = new W3sMenuElement();
         $contentValues = array("ContentId" => $this->content->getId(), "PageId" => 0, "Link" => w3sCommonFunctions::toI18n('This is a link'), "ExternalLink" => '', "Image" => '', "RolloverImage" => '', "Position" => $i);
         $newMenu->fromArray($contentValues);
         $result = $newMenu->save();
         if ($newMenu->isModified() && $result == 0) {
             $bRollBack = true;
             break;
         }
     }
     if (!$bRollBack) {
         // Everything was fine so W3StudioCMS commits to database
         $con->commit();
         $result = true;
     } else {
         // Something was wrong so W3StudioCMS aborts the operation and restores to previous status
         w3sPropelWorkaround::rollBack($con);
         $result = false;
     }
 }
开发者ID:jmp0207,项目名称:w3studiocms,代码行数:32,代码来源:w3sContentManagerMenu.class.php

示例8: executeSparkline

 public function executeSparkline()
 {
     /*
         $c = new Criteria();
       	$c->add(SfReviewTypeEntityPeer::ENTITY_ID, $this->politico->getId());
       	$c->add(SfReviewTypeEntityPeer::VALUE, 1);
       	$c->addAscendingOrderByColumn(SfReviewTypeEntityPeer::DATE);
       	$elements = SfReviewTypeEntityPeer::doSelect( $c );
     
       	$this->sparklineData = "";		
       	$spi = 0;
     foreach ($elements as $element) {
     	$this->sparklineData .= ($spi++>0?",":"").$element->getSum();
     }
     */
     $query = "select entity_id, month(date) as month, max(sum) as sum from sf_review_type_entity where value = 1 and entity_id = ? group by entity_id, month(date) order by month";
     $connection = Propel::getConnection();
     $statement = $connection->prepare($query);
     $statement->bindValue(1, $this->partido->getId());
     $statement->execute();
     $data = $statement->fetchAll(PDO::FETCH_OBJ);
     $this->sparklineData = "0, 0";
     $last = 0;
     foreach ($data as $element) {
         $this->sparklineData .= ", " . ($element->sum - $last);
         $last = $element->sum;
     }
     // select entity_id, month(date), value, sum from sf_review_type_entity where value = 1 group by entity_id, month(date)
 }
开发者ID:voota,项目名称:voota,代码行数:29,代码来源:components.class.php

示例9: getPopularValidLanguages

 public static function getPopularValidLanguages($max = 10)
 {
     $connection = Propel::getConnection();
     $languages = array_keys(sfConfig::get('app_languages'));
     foreach ($languages as $i => $language) {
         $languages[$i] = "'{$languages[$i]}'";
     }
     $query = 'SELECT %s as language, COUNT(*) as count
           FROM %s
           INNER JOIN %s ON %s = %s
           WHERE %s = false AND %s IN (%s)
           GROUP BY language
           ORDER BY count DESC';
     $query = sprintf($query, SnippetLanguagePeer::NAME, SnippetLanguagePeer::TABLE_NAME, SnippetPeer::TABLE_NAME, SnippetLanguagePeer::SNIPPET_ID, SnippetPeer::ID, SnippetPeer::DRAFT, SnippetLanguagePeer::NAME, implode(', ', $languages));
     $statement = $connection->prepareStatement($query);
     if ($max) {
         $statement->setLimit($max);
     }
     $resultset = $statement->executeQuery();
     $languages = array();
     $max_count = 0;
     while ($resultset->next()) {
         if (!$max_count) {
             $max_count = $resultset->getInt('count');
         }
         $languages[] = array('language' => $resultset->getString('language'), 'rank' => floor($resultset->getInt('count') / $max_count * 9 + 1), 'count' => $resultset->getInt('count'));
     }
     ksort($languages);
     return $languages;
 }
开发者ID:hoydaa,项目名称:snippets.hoydaa.org,代码行数:30,代码来源:SnippetLanguagePeer.php

示例10: execute

 /**
  * @see Command
  *
  * @throws \InvalidArgumentException When the target directory does not exist
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->writeSection($output, '[Propel] You are running the command: propel:database:drop');
     if ($input->getOption('force')) {
         if ('prod' === $this->getApplication()->getKernel()->getEnvironment()) {
             $this->writeSection($output, 'WARNING: you are about to drop a database in production !', 'bg=red;fg=white');
             if (false === $this->askConfirmation($output, 'Are you sure ? (y/n) ', false)) {
                 $output->writeln('Aborted, nice decision !');
                 return -2;
             }
         }
         list($name, $config) = $this->getConnection($input, $output);
         $dbName = $this->parseDbName($config['connection']['dsn']);
         $query = 'DROP DATABASE ' . $dbName . ';';
         try {
             $connection = \Propel::getConnection($name);
             $statement = $connection->prepare($query);
             $statement->execute();
             $output->writeln(sprintf('<info>Database <comment>%s</comment> has been dropped.</info>', $dbName));
         } catch (\Exception $e) {
             $this->writeSection($output, array('[Propel] Exception catched', '', $e->getMessage()), 'fg=white;bg=red');
         }
     } else {
         $output->writeln('<error>You have to use the "--force" option to drop the database.</error>');
     }
 }
开发者ID:hhamon,项目名称:PropelBundle,代码行数:31,代码来源:DatabaseDropCommand.php

示例11: getRecommendations

    /**
     * Returns objects of the same class and with similar ratings as the current rateable object.
     * 
     * This implementation is based on the 
     * OpenSlopeOne project by Chaoqun Fu, http://code.google.com/p/openslopeone/.
     *
     * @param BaseObject $object The rateable object for which to return other recommended object
     * @param int $limit The number of recommendation objects which should be returned. Use NULL for returning all recommended objects
     * @return array of sfRecommendationObject objects which wrap the recommended objects
     */
    public function getRecommendations(BaseObject $object, $limit = NULL)
    {
        $parser = new sfPropelSlopeOneSqlParser();
        $slopeQuery = 'SELECT 	item2_id AS id,
    												SUM(rating/times) AS rating
                    FROM sf_slope_one 
                    WHERE item1_id = :item_id AND 
													item1_model = :item_model AND
                          item1_model = item2_model
                    GROUP BY item2_id
                    ORDER BY rating DESC';
        $slopeQuery .= isset($limit) ? ' LIMIT ' . $limit : '';
        $connection = Propel::getConnection();
        $statement = $connection->prepare($parser->parse($slopeQuery));
        $statement->execute(array('item_id' => $object->getId(), 'item_model' => get_class($object)));
        $ratings = array();
        while ($result = $statement->fetch()) {
            $ratings[$result['id']] = $result['rating'];
        }
        $objects = call_user_func(array(get_class($object->getPeer()), 'retrieveByPKs'), array_keys($ratings));
        foreach ($objects as &$object) {
            $object = new sfSlopeOneRecommendation($object, $ratings[$object->getId()]);
        }
        return $objects;
    }
开发者ID:kasperg,项目名称:symfony-propel-slope-one-recommendations-plugin,代码行数:35,代码来源:sfPropelActAsSlopeOneRateableBehavior.php

示例12: update

 public function update($aData)
 {
     $con = Propel::getConnection(AppThreadPeer::DATABASE_NAME);
     try {
         $con->begin();
         $oApp = AppThreadPeer::retrieveByPK($aData['APP_UID'], $aData['APP_THREAD_INDEX']);
         if (is_object($oApp) && get_class($oApp) == 'AppThread') {
             $oApp->fromArray($aData, BasePeer::TYPE_FIELDNAME);
             if ($oApp->validate()) {
                 $res = $oApp->save();
                 $con->commit();
                 return $res;
             } else {
                 $msg = '';
                 foreach ($this->getValidationFailures() as $objValidationFailure) {
                     $msg .= $objValidationFailure->getMessage() . "<br/>";
                 }
                 throw new PropelException('The AppThread row cannot be created!', new PropelException($msg));
             }
         } else {
             $con->rollback();
             throw new Exception("This AppThread row doesn't exist!");
         }
     } catch (Exception $oError) {
         throw $oError;
     }
 }
开发者ID:emildev35,项目名称:processmaker,代码行数:27,代码来源:AppThread.php

示例13: prepareAndExecute

 public static function prepareAndExecute($sql, array $paramValueMap, $type = 'all', $fetchType = PDO::FETCH_ASSOC)
 {
     $con = Propel::getConnection();
     $stmt = $con->prepare($sql);
     foreach ($paramValueMap as $param => $v) {
         $stmt->bindValue($param, $v);
     }
     $rows = array();
     if ($stmt->execute()) {
         if ($type == 'single') {
             $rows = $stmt->fetch($fetchType);
         } else {
             if ($type == 'column') {
                 $rows = $stmt->fetchColumn();
             } else {
                 if ($type == 'all') {
                     $rows = $stmt->fetchAll($fetchType);
                 } else {
                     if ($type == 'execute') {
                         $rows = null;
                     } else {
                         $msg = "bad type passed: type({$type})";
                         throw new Exception("Error: {$msg}");
                     }
                 }
             }
         }
     } else {
         $msg = implode(',', $stmt->errorInfo());
         throw new Exception("Error: {$msg}");
     }
     return $rows;
 }
开发者ID:nidzix,项目名称:Airtime,代码行数:33,代码来源:Database.php

示例14: runQuery

 private function runQuery(sfWebRequest $request, $databaseName)
 {
     try {
         $e = null;
         $this->getResponse()->setContentType('text/plain');
         $query = $this->getRequestParameter('query');
         if (strlen($query) < 10) {
             // consider the query as bogus
             $e = "The Query seems to be too short. Try something like ?query=select * from smint_user.";
             $result = "";
             return $this->renderPartial('sqlquery/viewResult', array('result' => $result, 'query' => $query, 'exception' => $e));
         } else {
             // open database connection based on filedescpeer settings
             $con = Propel::getConnection($databaseName, Propel::CONNECTION_READ);
             // prepare statement
             $stmt = $con->prepare($query);
             $stmt->execute();
             // fetch the results
             $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
             return $this->renderPartial('sqlquery/viewResult', array('result' => $result, 'query' => $query, 'exception' => $e));
         }
     } catch (Exception $e) {
         $result = null;
         return $this->renderPartial('sqlquery/viewResult', array('result' => $result, 'query' => $query, 'exception' => $e));
     }
 }
开发者ID:EQ4,项目名称:smint,代码行数:26,代码来源:actions.class.php

示例15: execute

 public static function execute()
 {
     //Check if this is the version to apply the patch
     $count = 0;
     $task = new Task();
     if (patch::$isPathchable && method_exists($task, 'getTasGroupVariable')) {
         $con = Propel::getConnection("workflow");
         $stmt = $con->prepareStatement("select TAS_UID from TASK where TAS_ASSIGN_TYPE = 'SELF_SERVICE';");
         $recordSet = $stmt->executeQuery();
         $recordSet->next();
         $aRow = $recordSet->getRow();
         while ($aRow) {
             $tasUid = $aRow['TAS_UID'];
             $conUser = Propel::getConnection("workflow");
             $stmtUser = $conUser->prepareStatement("select * from TASK_USER where TAS_UID = '" . $tasUid . "';");
             $recordSetTaskUser = $stmtUser->executeQuery();
             if ($recordSetTaskUser->next()) {
                 echo "Patching uid: " . $tasUid . "\n";
                 //Set the values if they match the pattern
                 $conChange = Propel::getConnection("workflow");
                 $stmtChange = $conChange->prepareStatement("update TASK set TAS_GROUP_VARIABLE = '' where TAS_UID = '" . $tasUid . "';");
                 $recordResult = $stmtChange->executeQuery();
                 $count++;
             }
             $recordSet->next();
             $aRow = $recordSet->getRow();
         }
     }
     echo $count . " records where patched to use SELF_SERVICE feature.\n";
 }
开发者ID:bqevin,项目名称:processmaker,代码行数:30,代码来源:class.patch.php


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