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


PHP Database\DatabaseConnection类代码示例

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


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

示例1: setUp

 /**
  * Set up
  *
  * @return void
  */
 protected function setUp()
 {
     $this->database = $this->getMock(DatabaseConnection::class, array('exec_SELECTgetSingleRow'));
     $this->database->expects($this->any())->method('exec_SELECTgetSingleRow')->will($this->returnValue(array('uid' => 0, 'parent' => '')));
     $this->treeData = new TreeNode();
     $GLOBALS['TYPO3_DB'] = $this->database;
 }
开发者ID:rickymathew,项目名称:TYPO3.CMS,代码行数:12,代码来源:DatabaseTreeDataProviderTest.php

示例2: init

 /**
  * initializes this class
  *
  * @param integer $pageUid
  *
  * @return void
  */
 public function init($pageUid)
 {
     $this->setDatabaseConnection($GLOBALS['TYPO3_DB']);
     if (!$this->layoutSetup instanceof LayoutSetup) {
         if ($pageUid < 0) {
             $triggerElement = $this->databaseConnection->exec_SELECTgetSingleRow('pid', 'tt_content', 'uid = ' . -$pageUid);
             $pageUid = (int) $triggerElement['pid'];
         }
         $this->injectLayoutSetup(GeneralUtility::makeInstance(LayoutSetup::class)->init($pageUid));
     }
 }
开发者ID:stigfaerch,项目名称:gridelements,代码行数:18,代码来源:BackendUtilityGridelements.php

示例3: migrateTtNewsCategoryMountsToSysCategoryPerms

 /**
  * Migrate tt_news_categorymounts to category_pems in either be_groups or be_users
  *
  * @param string $table either be_groups or be_users
  */
 public function migrateTtNewsCategoryMountsToSysCategoryPerms($table)
 {
     /** @var \TYPO3\CMS\Core\DataHandling\DataHandler $dataHandler */
     $dataHandler = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
     $dataHandler->admin = TRUE;
     /* assign imported categories to be_groups or be_users */
     $whereClause = 'tt_news_categorymounts != \'\'' . BackendUtility::deleteClause($table);
     $beGroupsOrUsersWithTtNewsCategorymounts = $this->databaseConnection->exec_SELECTgetRows('*', $table, $whereClause);
     $data = array();
     foreach ((array) $beGroupsOrUsersWithTtNewsCategorymounts as $beGroupOrUser) {
         $ttNewsCategoryPermissions = GeneralUtility::trimExplode(',', $beGroupOrUser['tt_news_categorymounts']);
         $sysCategoryPermissions = array();
         foreach ($ttNewsCategoryPermissions as $ttNewsCategoryPermissionUid) {
             $whereClause = 'import_source = \'TT_NEWS_CATEGORY_IMPORT\' AND import_id = ' . $ttNewsCategoryPermissionUid;
             $sysCategory = $this->databaseConnection->exec_SELECTgetSingleRow('uid', 'sys_category', $whereClause);
             if (!empty($sysCategory)) {
                 $sysCategoryPermissions[] = $sysCategory['uid'];
             }
         }
         if (count($sysCategoryPermissions)) {
             $data[$table][$beGroupOrUser['uid']] = array('category_perms' => implode(',', $sysCategoryPermissions) . ',' . $beGroupOrUser['category_perms']);
         }
     }
     $dataHandler->start($data, array());
     $dataHandler->process_datamap();
 }
开发者ID:sr-amueller,项目名称:news_ttnewsimport,代码行数:31,代码来源:TTNewsCategoryImportService.php

示例4: truncate_multiple_tables_when_configured

 /**
  * @test
  */
 public function truncate_multiple_tables_when_configured()
 {
     $configuration = ['truncate' => ['test', 'test2', 'test3']];
     $processor = $this->getMockBuilder(Configuration::class)->disableOriginalConstructor()->getMock();
     $this->connection->expects($this->exactly(3))->method('exec_TRUNCATEquery')->withConsecutive(['test'], ['test2'], ['test3']);
     $this->fixture->execute($processor, $configuration);
 }
开发者ID:sirdiego,项目名称:importr,代码行数:10,代码来源:TruncateTableTest.php

示例5: run

 /**
  * @param \S3b0\ProjectRegistration\Scheduler\InfoMail\Task $task
  *
  * @return bool
  */
 public function run(\S3b0\ProjectRegistration\Scheduler\InfoMail\Task $task)
 {
     $settings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extensionName]);
     $upperLimit = new \DateTime();
     $lowerLimit = new \DateTime();
     $daysLeft = $settings['warnXDaysBeforeExpireDate'];
     $sender = [$task->getSenderAddress()];
     $receiver = [$task->getReceiverAddress()];
     $subject = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('infomail.subject', $this->extensionName);
     $this->databaseConnection = $GLOBALS['TYPO3_DB'];
     // Upper limit (expiry) = Current date + Days left
     $upperLimit->setTimestamp($upperLimit->getTimestamp() + $daysLeft * 86400);
     // Lower limit (expiry) = Current date + Days left - Scheduler frequency
     $lowerLimit->setTimestamp($lowerLimit->getTimestamp() + $daysLeft * 86400 - $task->getExecution()->getInterval());
     $where = "date_of_expiry > '{$lowerLimit->format('Y-m-d h:i:s')}' AND date_of_expiry < '{$upperLimit->format('Y-m-d h:i:s')}'";
     if ($this->databaseConnection->exec_SELECTcountRows('*', 'tx_projectregistration_domain_model_project', $where)) {
         $expiredProjects = $this->databaseConnection->exec_SELECTgetRows('project.*, registrant.name as registrant_name, registrant.company as registrant_company', 'tx_projectregistration_domain_model_project as project join tx_projectregistration_domain_model_person as registrant on project.registrant=registrant.uid', $where);
         $list = [];
         /** @var array $expiredProject */
         foreach ($expiredProjects as $expiredProject) {
             $list[] = "#{$expiredProject['uid']} - '{$expiredProject['title']}' by {$expiredProject['registrant_name']} ({$expiredProject['registrant_company']})";
         }
         $mailContent = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('infomail.message', $this->extensionName, [$daysLeft, '<li>' . implode('</li><li>', $list) . '</li>']);
         /** @var \TYPO3\CMS\Core\Mail\MailMessage $mail */
         $mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
         $mail->setContentType('text/html');
         /**
          * Email to sender
          */
         $mail->setFrom($sender)->setTo($receiver)->setPriority(1)->setSubject($subject)->setBody($mailContent)->send();
     }
     return true;
 }
开发者ID:S3b0,项目名称:project_registration,代码行数:38,代码来源:BusinessLogic.php

示例6: addDataSetsPageLanguageOverlayRows

 /**
  * @test
  */
 public function addDataSetsPageLanguageOverlayRows()
 {
     $input = ['effectivePid' => '23'];
     $expected = $input;
     $expected['pageLanguageOverlayRows'] = [0 => ['uid' => '1', 'pid' => '42', 'sys_language_uid' => '2']];
     $this->dbProphecy->exec_SELECTgetRows('*', 'pages_language_overlay', 'pid=23')->shouldBeCalled()->willReturn($expected['pageLanguageOverlayRows']);
     $this->assertSame($expected, $this->subject->addData($input));
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:11,代码来源:DatabasePageLanguageOverlayRowsTest.php

示例7: release

 /**
  * @return boolean TRUE on success, FALSE otherwise
  */
 public function release()
 {
     $res = $this->connection->sql_query(sprintf('SELECT RELEASE_LOCK("%s") AS res', $this->identifier));
     if ($res) {
         $releaseLockRes = $res->fetch_assoc();
         return (int) $releaseLockRes['res'] === 1;
     }
     return false;
 }
开发者ID:beyond-agentur,项目名称:pt_extbase,代码行数:12,代码来源:MySqlLockStrategy.php

示例8: registerSession

 /**
  * @param \TYPO3\Sso\Domain\Model\FrontendUser $frontendUser
  *
  * @throws EmptyUserException
  * @return void
  */
 public function registerSession($frontendUser)
 {
     if (!$frontendUser) {
         throw new EmptyUserException('No user given that can be dropped into the session.', 1329749957);
     }
     $row = $this->db->exec_SELECTgetSingleRow('*', 'fe_users', 'uid = ' . $frontendUser->getUid());
     $this->getFeUser()->createUserSession($row);
     $this->getFeUser()->setSessionCookie();
 }
开发者ID:t3dd,项目名称:T3DD16.Backend,代码行数:15,代码来源:AuthenticationService.php

示例9: prepareSelectQueryCreateValidQuery

 /**
  * @test
  *
  * @return void
  */
 public function prepareSelectQueryCreateValidQuery()
 {
     $this->assertTrue($this->subject->admin_query("INSERT INTO {$this->testTable} ({$this->testField}) VALUES ('aTestValue')"));
     $preparedQuery = $this->subject->prepare_SELECTquery("{$this->testField},{$this->anotherTestField}", $this->testTable, 'id=:id', '', '', '', [':id' => 1]);
     $preparedQuery->execute();
     $result = $preparedQuery->fetch();
     $expectedResult = [$this->testField => 'aTestValue', $this->anotherTestField => null];
     $this->assertSame($expectedResult, $result);
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:14,代码来源:PreparedStatementTest.php

示例10: getFormUidFromTtContentUid

 /**
  * Return Form Uid from content element
  *
  * @param int $ttContentUid
  * @return int
  */
 protected function getFormUidFromTtContentUid($ttContentUid)
 {
     $row = $this->databaseConnection->exec_SELECTgetSingleRow('pi_flexform', 'tt_content', 'uid=' . (int) $ttContentUid);
     $flexform = GeneralUtility::xml2array($row['pi_flexform']);
     if (is_array($flexform) && isset($flexform['data']['main']['lDEF']['settings.flexform.main.form']['vDEF'])) {
         return (int) $flexform['data']['main']['lDEF']['settings.flexform.main.form']['vDEF'];
     }
     return 0;
 }
开发者ID:bernhardberger,项目名称:powermail,代码行数:15,代码来源:FieldSelectorUserFunc.php

示例11: databaseResultIsUsedWhenNoCachedResultIsPresent

 /**
  * @test
  */
 public function databaseResultIsUsedWhenNoCachedResultIsPresent()
 {
     $fakeConfiguration = array('select.' => array('checkRootPageId' => true, 'checkLanguage' => true, 'SELECT' => '', 'FROM' => '', 'ADD_WHERE' => '', 'GROUP_BY' => '', 'ORDER_BY' => ''), 'limit');
     $this->configurationMock->expects($this->once())->method('getSearchFrequentSearchesConfiguration')->will($this->returnValue($fakeConfiguration));
     $this->databaseMock->expects($this->once())->method('exec_SELECTgetRows')->will($this->returnValue(array(array('search_term' => 'my search', 'hits' => 22))));
     //we fake that we have no frequent searches in the cache and therefore expect that the database will be queried
     $this->fakeIdentifierNotInCache();
     $frequentTerms = $this->frequentSearchesService->getFrequentSearchTerms();
     $this->assertSame($frequentTerms, array('my search' => 22), 'Could not retrieve frequent search terms');
 }
开发者ID:sitegeist,项目名称:ext-solr,代码行数:13,代码来源:FrequentSearchesServiceTest.php

示例12: validateParentUid

 /**
  * @param $uid
  * @param $parentUid
  */
 function validateParentUid($uid, $parentUid)
 {
     # Always validate for new forums.
     if ($uid == -1) {
         return;
     }
     $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_forums', 'parentID=' . intval($uid) . ' AND deleted=0 ' . $this->parent->getStoragePIDQuery());
     if ($this->databaseHandle->sql_num_rows($res) > 0 && $parentUid != 0) {
         $this->addErrorForField('parent', 'no-nested-forums', array($this->databaseHandle->sql_num_rows($res)));
     }
 }
开发者ID:rabe69,项目名称:mm_forum,代码行数:15,代码来源:class.tx_mmforum_frontendadministration_validator.php

示例13: addCityItems

 /**
  * add cities to selectbox.
  *
  * @param array                              $parentArray
  * @param \TYPO3\CMS\Backend\Form\FormEngine $fObj
  */
 public function addCityItems(array $parentArray, \TYPO3\CMS\Backend\Form\FormEngine $fObj)
 {
     $this->init();
     $rows = $this->database->exec_SELECTgetRows('city', 'tx_clubdirectory_domain_model_address', '1=1 ' . BackendUtility::BEenableFields('tx_clubdirectory_domain_model_address') . BackendUtility::deleteClause('tx_clubdirectory_domain_model_address'), 'city', 'city', '');
     foreach ($rows as $row) {
         $item = array();
         $item[0] = $row['city'];
         $item[1] = $row['city'];
         $item[2] = null;
         $parentArray['items'][] = $item;
     }
 }
开发者ID:jweiland-net,项目名称:clubdirectory,代码行数:18,代码来源:Cities.php

示例14: expectOutput

 /**
  * Check if the note plugin expects output. If there are no sys_note records on the given
  * pages, the extbase bootstrap doesn't have to run the complete plugin.
  * This mechanism should increase the performance of the hooked backend modules heavily.
  *
  * @param array $arguments Arguments for the extbase plugin
  * @return bool
  */
 protected function expectOutput(array $arguments = array())
 {
     // no pids set
     if (!isset($arguments['pids']) || empty($arguments['pids']) || empty($GLOBALS['BE_USER']->user['uid'])) {
         return false;
     }
     $pidList = $this->databaseConnection->cleanIntList($arguments['pids']);
     if (empty($pidList)) {
         return false;
     }
     // check if there are records
     return $this->databaseConnection->exec_SELECTcountRows('*', 'sys_note', 'pid IN (' . $pidList . ')' . BackendUtility::deleteClause('sys_note')) > 0;
 }
开发者ID:graurus,项目名称:testgit_t37,代码行数:21,代码来源:Bootstrap.php

示例15: getRecords

 /**
  * @param int               $startPage
  * @param array             $basePages
  * @param SitemapController $obj
  *
  * @return array
  */
 public function getRecords($startPage, $basePages, SitemapController $obj)
 {
     $nodes = array();
     foreach ($basePages as $uid) {
         if ($this->currentLanguageUid) {
             $fields = $this->cObject->enableFields('pages_language_overlay');
             $overlay = $this->database->exec_SELECTgetSingleRow('uid', 'pages_language_overlay', ' pid=' . intval($uid) . ' AND sys_language_uid=' . $this->currentLanguageUid . $fields);
             if (!is_array($overlay)) {
                 continue;
             }
         }
         // Build URL
         $url = $obj->getUriBuilder()->setTargetPageUid($uid)->build();
         // can't generate a valid url
         if (!strlen($url)) {
             continue;
         }
         // Get Record
         $record = BackendUtility::getRecord('pages', $uid);
         // exclude Doctypes
         if (in_array($record['doktype'], array(4))) {
             continue;
         }
         // Check FE Access
         if ($record['fe_group'] != 0) {
             continue;
         }
         $rootLineList = $GLOBALS['TSFE']->sys_page->getRootLine($record['uid']);
         $addToNode = true;
         foreach ($rootLineList as $rootPage) {
             if ($rootPage['extendToSubpages'] == 1 && $rootPage['fe_group'] != 0) {
                 $addToNode = false;
                 break;
             }
         }
         if ($addToNode == false) {
             continue;
         }
         // Build Node
         $node = new Node();
         $node->setLoc($url);
         $node->setPriority($this->getPriority($startPage, $record));
         $node->setChangefreq(SitemapDataService::mapTimeout2Period($record['cache_timeout']));
         $node->setLastmod($this->getModifiedDate($record));
         #$geo = new Geo();
         #$geo->setFormat('kml');
         #$node->setGeo($geo);
         $nodes[] = $node;
     }
     return $nodes;
 }
开发者ID:rsennert,项目名称:google_services,代码行数:58,代码来源:LanguagePages.php


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