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


PHP DatabaseConnection::sql_affected_rows方法代码示例

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


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

示例1: limitTableRecords

 /**
  * Limits amount of records in the table. This does not run often.
  * Records are removed in the uid order (oldest first). This is not a true
  * clean up, which would be based on the last access timestamp but good
  * enough to maintain performance.
  *
  * @param string $tableName
  * @return bool
  */
 protected function limitTableRecords($tableName)
 {
     $cleanedUp = false;
     if (mt_rand(0, mt_getrandmax()) % 5 == 0) {
         $this->databaseConnection->sql_query('DELETE FROM ' . $tableName . ' WHERE uid <= (SELECT t2.uid FROM (SELECT uid FROM ' . $tableName . ' ORDER BY uid DESC LIMIT ' . self::$maximumNumberOfRecords . ',1) t2)');
         $cleanedUp = $this->databaseConnection->sql_affected_rows() > 0;
     }
     return $cleanedUp;
 }
开发者ID:olek07,项目名称:GiGaBonus,代码行数:18,代码来源:DatabaseCache.php

示例2: useNonce

 /**
  * Checks if this nonce was already used
  *
  * @param string $serverUrl Server URL
  * @param int $timestamp Time stamp
  * @param string $salt Nonce value
  * @return bool TRUE if nonce was not used before anc can be used now
  */
 public function useNonce($serverUrl, $timestamp, $salt)
 {
     $result = false;
     if (abs($timestamp - time()) < $GLOBALS['Auth_OpenID_SKEW']) {
         $values = array('crdate' => time(), 'salt' => $salt, 'server_url' => $serverUrl, 'tstamp' => $timestamp);
         $this->databaseConnection->exec_INSERTquery(self::NONCE_TABLE_NAME, $values);
         $affectedRows = $this->databaseConnection->sql_affected_rows();
         $result = $affectedRows > 0;
     }
     return $result;
 }
开发者ID:Gregpl,项目名称:TYPO3.CMS,代码行数:19,代码来源:OpenidStore.php

示例3: migrateCategoryMmRecords

 /**
  * Create new category MM records
  *
  * @param array $oldNewCategoryUidMapping
  */
 protected function migrateCategoryMmRecords(array $oldNewCategoryUidMapping)
 {
     $newMmCount = 0;
     $oldMmRecords = $this->databaseConnection->exec_SELECTgetRows('uid_local, uid_foreign, tablenames, sorting', 'tx_news_domain_model_news_category_mm', '');
     foreach ($oldMmRecords as $oldMmRecord) {
         $oldCategoryUid = $oldMmRecord['uid_foreign'];
         if (!empty($oldNewCategoryUidMapping[$oldCategoryUid])) {
             $newMmRecord = array('uid_local' => $oldNewCategoryUidMapping[$oldCategoryUid], 'uid_foreign' => $oldMmRecord['uid_local'], 'tablenames' => $oldMmRecord['tablenames'] ?: 'tx_news_domain_model_news', 'sorting_foreign' => $oldMmRecord['sorting'], 'fieldname' => 'categories');
             // check if relation already exists
             $foundRelations = $this->databaseConnection->exec_SELECTcountRows('uid_local', 'sys_category_record_mm', 'uid_local=' . $newMmRecord['uid_local'] . ' AND uid_foreign=' . $newMmRecord['uid_foreign'] . ' AND tablenames="' . $newMmRecord['tablenames'] . '"' . ' AND fieldname="' . $newMmRecord['fieldname'] . '"');
             if ($foundRelations === 0) {
                 $this->databaseConnection->exec_INSERTquery('sys_category_record_mm', $newMmRecord);
                 if ($this->databaseConnection->sql_affected_rows()) {
                     $newMmCount++;
                 }
             }
         }
     }
     $message = 'Created ' . $newMmCount . ' new MM relations';
     $status = FlashMessage::INFO;
     $title = '';
     $this->messageArray[] = array($status, $title, $message);
 }
开发者ID:kalypso63,项目名称:news,代码行数:28,代码来源:class.ext_update.php

示例4: CLI_run

    /**
     * Running the functionality of the CLI (crawling URLs from queue)
     *
     * @param  int $countInARun
     * @param  int $sleepTime
     * @param  int $sleepAfterFinish
     * @return string                   Status message
     */
    public function CLI_run($countInARun, $sleepTime, $sleepAfterFinish)
    {
        $result = 0;
        $counter = 0;
        // First, run hooks:
        $this->CLI_runHooks();
        // Clean up the queue
        if (intval($this->extensionSettings['purgeQueueDays']) > 0) {
            $purgeDate = $this->getCurrentTime() - 24 * 60 * 60 * intval($this->extensionSettings['purgeQueueDays']);
            $del = $this->db->exec_DELETEquery('tx_crawler_queue', 'exec_time!=0 AND exec_time<' . $purgeDate);
        }
        // Select entries:
        //TODO Shouldn't this reside within the transaction?
        $rows = $this->db->exec_SELECTgetRows('qid,scheduled', 'tx_crawler_queue', 'exec_time=0
				AND process_scheduled= 0
				AND scheduled<=' . $this->getCurrentTime(), '', 'scheduled, qid', intval($countInARun));
        if (count($rows) > 0) {
            $quidList = array();
            foreach ($rows as $r) {
                $quidList[] = $r['qid'];
            }
            $processId = $this->CLI_buildProcessId();
            //reserve queue entrys for process
            $this->db->sql_query('BEGIN');
            //TODO make sure we're not taking assigned queue-entires
            $this->db->exec_UPDATEquery('tx_crawler_queue', 'qid IN (' . implode(',', $quidList) . ')', array('process_scheduled' => intval($this->getCurrentTime()), 'process_id' => $processId));
            //save the number of assigned queue entrys to determine who many have been processed later
            $numberOfAffectedRows = $this->db->sql_affected_rows();
            $this->db->exec_UPDATEquery('tx_crawler_process', "process_id = '" . $processId . "'", array('assigned_items_count' => intval($numberOfAffectedRows)));
            if ($numberOfAffectedRows == count($quidList)) {
                $this->db->sql_query('COMMIT');
            } else {
                $this->db->sql_query('ROLLBACK');
                $this->CLI_debug("Nothing processed due to multi-process collision (" . $this->CLI_buildProcessId() . ")");
                return $result | self::CLI_STATUS_ABORTED;
            }
            foreach ($rows as $r) {
                $result |= $this->readUrl($r['qid']);
                $counter++;
                usleep(intval($sleepTime));
                // Just to relax the system
                // if during the start and the current read url the cli has been disable we need to return from the function
                // mark the process NOT as ended.
                if ($this->getDisabled()) {
                    return $result | self::CLI_STATUS_ABORTED;
                }
                if (!$this->CLI_checkIfProcessIsActive($this->CLI_buildProcessId())) {
                    $this->CLI_debug("conflict / timeout (" . $this->CLI_buildProcessId() . ")");
                    //TODO might need an additional returncode
                    $result |= self::CLI_STATUS_ABORTED;
                    break;
                    //possible timeout
                }
            }
            sleep(intval($sleepAfterFinish));
            $msg = 'Rows: ' . $counter;
            $this->CLI_debug($msg . " (" . $this->CLI_buildProcessId() . ")");
        } else {
            $this->CLI_debug("Nothing within queue which needs to be processed (" . $this->CLI_buildProcessId() . ")");
        }
        if ($counter > 0) {
            $result |= self::CLI_STATUS_PROCESSED;
        }
        return $result;
    }
开发者ID:nawork,项目名称:crawler,代码行数:73,代码来源:class.tx_crawler_lib.php

示例5: migrateEuLdapConfiguration


//.........这里部分代码省略.........
         if ($hasBackendAuthentication) {
             $mapping = array();
             $mapping[] = 'tstamp = ' . (!empty($legacy['timestamp']) ? '<' . $legacy['timestamp'] . '>' : '{DATE}');
             switch ($legacy['servertype']) {
                 case 0:
                 case 1:
                     $mapping[] = 'usergroup = <memberof>';
                     $data['be_groups_filter'] = '(objectClass=posixGroup)';
                     break;
                 case 2:
                     $mapping[] = 'usergroup = <groupmembership>';
                     $data['be_groups_filter'] = '(objectClass=posixGroup)';
                     break;
                 case 3:
                     $data['be_groups_filter'] = '(&(memberUid={USERUID})(objectClass=posixGroup))';
                     break;
             }
             $mapping[] = 'realName = <' . $legacy['name'] . '>';
             if (!empty($legacy['mail'])) {
                 $mapping[] = 'email = <' . $legacy['mail'] . '>';
             }
             $data['be_users_mapping'] = implode(LF, $mapping);
         }
         if ($hasFrontendAuthentication) {
             $mapping = array();
             $mapping[] = 'pid = ' . (int) $legacy['feuser_pid'];
             $mapping[] = 'tstamp = ' . (!empty($legacy['timestamp']) ? '<' . $legacy['timestamp'] . '>' : '{DATE}');
             switch ($legacy['servertype']) {
                 case 0:
                 case 1:
                     $mapping[] = 'usergroup = <memberof>';
                     $data['fe_groups_filter'] = '(objectClass=posixGroup)';
                     break;
                 case 2:
                     $mapping[] = 'usergroup = <groupmembership>';
                     $data['fe_groups_filter'] = '(objectClass=posixGroup)';
                     break;
                 case 3:
                     $data['fe_groups_filter'] = '(&(memberUid={USERUID})(objectClass=posixGroup))';
                     break;
             }
             if (!empty($legacy['mail'])) {
                 $mapping[] = 'email = <' . $legacy['mail'] . '>';
             }
             $mapping[] = 'name = <' . $legacy['name'] . '>';
             if (!empty($legacy['address'])) {
                 $mapping[] = 'address = <' . $legacy['address'] . '>';
             }
             if (!empty($legacy['zip'])) {
                 $mapping[] = 'zip = <' . $legacy['zip'] . '>';
             }
             if (!empty($legacy['city'])) {
                 $mapping[] = 'city = <' . $legacy['city'] . '>';
             }
             if (!empty($legacy['country'])) {
                 $mapping[] = 'country = <' . $legacy['country'] . '>';
             }
             if (!empty($legacy['phone'])) {
                 $mapping[] = 'telephone = <' . $legacy['phone'] . '>';
             }
             if (!empty($legacy['fax'])) {
                 $mapping[] = 'fax = <' . $legacy['fax'] . '>';
             }
             if (!empty($legacy['www'])) {
                 $mapping[] = 'www = <' . $legacy['www'] . '>';
             }
             $additionalInstructions = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $legacy['map_additional_fields'], TRUE);
             foreach ($additionalInstructions as $additionalInstruction) {
                 list($dbField, $ldapField) = explode('=', $additionalInstruction, 2);
                 $mapping[] = $dbField . ' = <' . $ldapField . '>';
             }
             $data['fe_users_mapping'] = implode(LF, $mapping);
         }
         if ($data['be_groups_required'] === '*') {
             // Replace '*' by every local BE group
             $groups = $this->databaseConnection->exec_SELECTgetRows('uid', 'be_groups', 'hidden=0 AND deleted=0 AND tx_igldapssoauth_dn=\'\' AND eu_ldap=0', '', '', '', 'uid');
             $data['be_groups_required'] = implode(',', array_keys($groups));
         }
         if ($data['fe_groups_required'] === '*') {
             // Replace '*' by every local FE group
             $groups = $this->databaseConnection->exec_SELECTgetRows('uid', 'fe_groups', 'hidden=0 AND deleted=0 AND tx_igldapssoauth_dn=\'\' AND eu_ldap=0', '', '', '', 'uid');
             $data['fe_groups_required'] = implode(',', array_keys($groups));
         }
         if ($legacy['only_emailusers'] == 1) {
             $emailAttribute = !empty($legacy['mail']) ? $legacy['mail'] : 'mail';
             if ($hasBackendAuthentication) {
                 $data['be_users_filter'] = sprintf('(&%s(%s=*))', $data['be_users_filter'], $emailAttribute);
             }
             if ($hasFrontendAuthentication) {
                 $data['fe_users_filter'] = sprintf('(&%s(%s=*))', $data['fe_users_filter'], $emailAttribute);
             }
         }
         // Insert the migrated record to ig_ldap_sso_auth
         $this->databaseConnection->exec_INSERTquery($this->table, $data);
         if ($this->databaseConnection->sql_affected_rows() == 1) {
             $this->databaseConnection->exec_UPDATEquery('tx_euldap_server', 'uid=' . $legacy['uid'], array('tx_igldapssoauth_migrated' => 1));
         }
     }
     $out[] = $this->formatOk('Successfully migrated eu_ldap configuration records.');
 }
开发者ID:woehrlag,项目名称:Intranet,代码行数:101,代码来源:class.ext_update.php

示例6: sqlAffectedRowsReturnsCorrectAmountOfRows

 /**
  * @test
  *
  * @return void
  */
 public function sqlAffectedRowsReturnsCorrectAmountOfRows()
 {
     $this->subject->exec_INSERTquery($this->testTable, [$this->testField => 'test']);
     $this->assertEquals(1, $this->subject->sql_affected_rows());
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:10,代码来源:DatabaseConnectionTest.php


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