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


PHP DatabaseConnection::sql_num_rows方法代码示例

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


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

示例1: 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

示例2: loadFromDB

 function loadFromDB($pid = -1)
 {
     $andWhere = '';
     if ($pid + 1) {
         $andWhere = ' AND pid=' . $pid;
     }
     $res = $this->databaseHandle->exec_SELECTquery('*', $this->getTableName(), 'uid=' . $this->getUid() . ' AND deleted=0 ' . $andWhere);
     if ($this->databaseHandle->sql_num_rows($res) == 0) {
         $this->data = null;
         $this->origData = array();
     } else {
         $this->data = $this->origData = $this->databaseHandle->sql_fetch_assoc($res);
     }
     $this->loaded = true;
 }
开发者ID:rabe69,项目名称:mm_forum,代码行数:15,代码来源:class.tx_mmforum_data.php

示例3: migrateDamReferencesToFalReferences

 /**
  * Migrate dam references to fal references
  *
  * @param \mysqli_result $result
  * @param string $table
  * @param string $type
  * @param array $fieldnameMapping Re-map fieldnames e.g.
  *    tx_damnews_dam_images => tx_falttnews_fal_images
  *
  * @return void
  */
 protected function migrateDamReferencesToFalReferences($result, $table, $type, $fieldnameMapping = array())
 {
     $counter = 0;
     $total = $this->database->sql_num_rows($result);
     $this->controller->infoMessage('Found ' . $total . ' ' . $table . ' records with a dam ' . $type);
     while ($record = $this->database->sql_fetch_assoc($result)) {
         $identifier = $this->getFullFileName($record);
         try {
             $fileObject = $this->storageObject->getFile($identifier);
         } catch (\Exception $e) {
             // If file is not found
             // getFile will throw an invalidArgumentException if the file
             // does not exist. Create an empty file to avoid this. This is
             // usefull in a development environment that has the production
             // database but not all the physical files.
             try {
                 GeneralUtility::mkdir_deep(PATH_site . $this->storageBasePath . dirname($identifier));
             } catch (\Exception $e) {
                 $this->controller->errorMessage('Unable to create directory: ' . PATH_site . $this->storageBasePath . $identifier);
                 continue;
             }
             $config = $this->controller->getConfiguration();
             if (isset($config['createMissingFiles']) && (int) $config['createMissingFiles']) {
                 $this->controller->infoMessage('Creating empty missing file: ' . PATH_site . $this->storageBasePath . $identifier);
                 try {
                     GeneralUtility::writeFile(PATH_site . $this->storageBasePath . $identifier, '');
                 } catch (\Exception $e) {
                     $this->controller->errorMessage('Unable to create file: ' . PATH_site . $this->storageBasePath . $identifier);
                     continue;
                 }
             } else {
                 $this->controller->errorMessage('File not found: ' . PATH_site . $this->storageBasePath . $identifier);
                 continue;
             }
             $fileObject = $this->storageObject->getFile($identifier);
         }
         if ($fileObject instanceof \TYPO3\CMS\Core\Resource\File) {
             if ($fileObject->isMissing()) {
                 $this->controller->warningMessage('FAL did not find any file resource for DAM record. DAM uid: ' . $record['uid'] . ': "' . $identifier . '"');
                 continue;
             }
             $record['uid_local'] = $fileObject->getUid();
             foreach ($fieldnameMapping as $old => $new) {
                 if ($record['ident'] === $old) {
                     $record['ident'] = $new;
                 }
             }
             $progress = number_format(100 * ($counter++ / $total), 1) . '% of ' . $total;
             if (!$this->doesFileReferenceExist($record)) {
                 $insertData = array('tstamp' => time(), 'crdate' => time(), 'cruser_id' => $GLOBALS['BE_USER']->user['uid'], 'uid_local' => $record['uid_local'], 'uid_foreign' => (int) $record['uid_foreign'], 'sorting' => (int) $record['sorting'], 'sorting_foreign' => (int) $record['sorting_foreign'], 'tablenames' => (string) $record['tablenames'], 'fieldname' => (string) $record['ident'], 'table_local' => 'sys_file', 'pid' => $record['item_pid'], 'l10n_diffsource' => (string) $record['l18n_diffsource']);
                 $this->database->exec_INSERTquery('sys_file_reference', $insertData);
                 $this->amountOfMigratedRecords++;
                 $this->controller->message($progress . ' Migrating relation for ' . (string) $record['tablenames'] . ' uid: ' . $record['item_uid'] . ' dam uid: ' . $record['dam_uid'] . ' to fal uid: ' . $record['uid_local']);
             } else {
                 $this->controller->message($progress . ' Reference already exists for uid: ' . (int) $record['item_uid']);
             }
         }
     }
     $this->database->sql_free_result($result);
 }
开发者ID:svenhartmann,项目名称:t3ext-dam_falmigration,代码行数:71,代码来源:AbstractService.php

示例4: importingExtension

 /**
  * @test
  */
 public function importingExtension()
 {
     $this->importExtensions(array('extbase'));
     /** @var mysqli_result|resource $res */
     $res = $this->db->sql_query('show tables');
     $rows = $this->db->sql_num_rows($res);
     self::assertNotSame(0, $rows);
 }
开发者ID:TrueType,项目名称:phpunit,代码行数:11,代码来源:TestCaseTest.php

示例5: getRankByPostCount

 /**
  * Determines the user's rank by his/her post count.
  *
  * @author  Martin Helmich <m.helmich@mittwald.de>
  * @version 2007-06-06
  * @param   int   $post_count The user's post count.
  * @return  array             The regarding user rank as associative array.
  */
 function getRankByPostCount($post_count)
 {
     $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_ranks', 'minPosts <= ' . $post_count . ' AND deleted=0 AND hidden=0 AND special=0', '', 'minPosts DESC');
     if ($this->databaseHandle->sql_num_rows($res) == 0) {
         return 'error';
     } else {
         return $this->databaseHandle->sql_fetch_assoc($res);
     }
 }
开发者ID:rabe69,项目名称:mm_forum,代码行数:17,代码来源:class.tx_mmforum_ranksfe.php

示例6: getForumUIDByTopic

 /**
  *
  * Retrievs a topic's forum UID.
  *
  * @author  Martin Helmich <m.helmich@mittwald.de>
  * @version 2007-07-21
  * @param   int $topic_uid The topic's UID
  * @return  int            The forum's UID
  */
 function getForumUIDByTopic($topic_uid)
 {
     $topic_uid = intval($topic_uid);
     $res = $this->databaseHandle->exec_SELECTquery('forum_id', 'tx_mmforum_topics', 'uid=' . $topic_uid . ' AND deleted=0');
     if ($this->databaseHandle->sql_num_rows($res) > 0) {
         list($forum_uid) = $this->databaseHandle->sql_fetch_row($res);
         return $forum_uid;
     } else {
         return false;
     }
 }
开发者ID:rabe69,项目名称:mm_forum,代码行数:20,代码来源:class.tx_mmforum_postfactory.php

示例7: moveForumDown

    /**
     *
     * Moves a forum downwards.
     *
     * @access private
     * @param  Integer $forumUid The UID of the forum that is to be moved.
     * @return void|bool
     */
    function moveForumDown($forumUid)
    {
        $forumData = $this->p->getBoardData($forumUid);
        if (!$this->checkActionAllowance($forumData['parentID'] == 0 ? 'category' : 'forum', 'order')) {
            $this->flashmessage = $this->l('access-error');
            return FALSE;
        }
        $res = $this->databaseHandle->exec_SELECTquery('uid, sorting', 'tx_mmforum_forums', 'deleted=0 AND parentID=' . $forumData['parentID'] . '
					                            AND sorting > ' . $forumData['sorting'], '', 'sorting ASC', 1);
        if ($this->databaseHandle->sql_num_rows($res) == 0) {
            return;
        }
        list($lowerUid, $lowerSorting) = $this->databaseHandle->sql_fetch_row($res);
        $this->databaseHandle->exec_UPDATEquery('tx_mmforum_forums', 'uid=' . $forumData['uid'], array('sorting' => $lowerSorting, 'tstamp' => $GLOBALS['EXEC_TIME']));
        $this->databaseHandle->exec_UPDATEquery('tx_mmforum_forums', 'uid=' . $lowerUid, array('sorting' => $forumData['sorting'], 'tstamp' => $GLOBALS['EXEC_TIME']));
    }
开发者ID:rabe69,项目名称:mm_forum,代码行数:24,代码来源:class.tx_mmforum_frontendadministration.php

示例8: convertGroups

 /**
  * Converts CHC Forum groups into ordinary fe_groups.
  * This function converts a list of CHC forum groups into a list of the
  * fe_groups contained in this forum group. This is necessary since the
  * mm_forum extension - unlike the CHC Forum - works with the fe_groups
  * table directly.
  * There will be a slight data loss regarding specific users that are
  * members of a CHC group. These users will not be included in the result,
  * since in the mm_forum access rights are handled using fe_groups ONLY.
  *
  * @author  Martin Helmich <m.helmich@mittwald.de>
  * @version 2007-10-08
  * @param   string $groups A commaseperated list of CHC forum group UIDs.
  * @return  string         The UIDs of the fe_groups contained in the CHC
  *                         forum groups submitted as parameter as commaseperated
  *                         list.
  */
 function convertGroups($groups)
 {
     $groupArray = GeneralUtility::intExplode(',', $groups);
     $resultFeGroups = array();
     foreach ($groupArray as $group) {
         $res = $this->dbObj->exec_SELECTquery('forumgroup_groups', 'tx_chcforum_forumgroup', 'uid=' . $group . ' AND deleted=0');
         if (!$res || !$this->dbObj->sql_num_rows($res)) {
             continue;
         }
         list($feGroups) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
         $feGroupArray = GeneralUtility::intExplode(',', $feGroups);
         foreach ($feGroupArray as $feGroup) {
             $resultFeGroups[] = $feGroup;
         }
     }
     return implode(',', $resultFeGroups);
 }
开发者ID:rabe69,项目名称:mm_forum,代码行数:34,代码来源:class.tx_mmforum_chcimport.php

示例9: addSubscription

 /**
  * Adds a topic to a (logged in) user's list of email subscriptions.
  *
  * @param  \tx_mmforum_base $forumObj The plugin object
  * @param  string $topicId The topic identifier
  * @param $feUserId
  * @return bool             Whether it worked or not
  */
 function addSubscription(\tx_mmforum_base $forumObj, $topicId, $feUserId)
 {
     $feUserId = intval($feUserId);
     $topicId = intval($topicId);
     if ($feUserId && $topicId) {
         // Executing database operations
         $res = $this->databaseHandle->exec_SELECTquery('uid', 'tx_mmforum_topicmail', 'user_id = ' . $feUserId . ' AND topic_id = ' . $topicId . $forumObj->getStoragePIDQuery());
         if ($this->databaseHandle->sql_num_rows($res) < 1) {
             $insertData = array('pid' => $forumObj->getStoragePID(), 'tstamp' => $GLOBALS['EXEC_TIME'], 'crdate' => $GLOBALS['EXEC_TIME'], 'topic_id' => $topicId, 'user_id' => $feUserId);
             return $this->databaseHandle->exec_INSERTquery('tx_mmforum_topicmail', $insertData);
         } else {
             // it's already added, so "it worked"
             return true;
         }
     }
     // invalid parameters
     return false;
 }
开发者ID:rabe69,项目名称:mm_forum,代码行数:26,代码来源:class.tx_mmforum_havealook.php

示例10: wordAdd

 /**
  * Inserts a new word into the search index table and returns it's UID.
  * If the word already exists in the search index, just the UID is returned.
  * @param string $word The word to be inserted
  * @return int         The word's UID
  */
 function wordAdd($word)
 {
     // Attempt to load word from database
     $res = $this->databaseHandle->exec_SELECTquery('uid', 'tx_mmforum_wordlist', "word=" . $this->databaseHandle->fullQuoteStr($word, 'tx_mmforum_wordlist') . " " . $this->getPidQuery($this->conf));
     if (!$res) {
         echo $this->databaseHandle->sql_error() . '<hr>';
     }
     // If words already exists, just return the UID
     if ($this->databaseHandle->sql_num_rows($res) > 0) {
         list($uid) = $this->databaseHandle->sql_fetch_row($res);
     } else {
         // Compost insert query
         $insertArray = array('pid' => $this->getFirstPid($this->conf), 'word' => $word, 'metaphone' => metaphone($word));
         // Execute insert query
         $this->databaseHandle->exec_INSERTquery('tx_mmforum_wordlist', $insertArray);
         $uid = $this->databaseHandle->sql_insert_id();
     }
     return $uid;
 }
开发者ID:rabe69,项目名称:mm_forum,代码行数:25,代码来源:class.tx_mmforum_indexing.php

示例11: get

 function get($data)
 {
     if (is_int($data)) {
         /* Load record from database */
         $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_userfields', 'uid=' . intval($data));
         if ($this->databaseHandle->sql_num_rows($res) == 0) {
             return null;
         }
         $arr = $this->databaseHandle->sql_fetch_assoc($res);
     } else {
         $arr = $data;
     }
     /* Unserialize array with meta information */
     $arr['meta'] = unserialize($arr['meta']);
     /* Parse configuration TypoScript */
     $parser =& $this->userLib->getTSParser();
     $parser->setup = array();
     $parser->parse($arr['config']);
     $arr['config_parsed'] = $parser->setup;
     /* Do some corrections for backwards compatibility */
     if (!$arr['meta']['label']['default']) {
         $arr['meta']['label']['default'] = $arr['label'];
     }
     if (!$arr['meta']['type']) {
         $arr['meta']['type'] = 'custom';
     }
     if (!$arr['meta']['link'] && $arr['config_parsed']['datasource']) {
         $arr['meta']['link'] = $arr['config_parsed']['datasource'];
     }
     if (!isset($arr['meta']['required']) && isset($arr['config_parsed']['required'])) {
         $arr['meta']['required'] = $arr['config_parsed']['required'] ? true : false;
     }
     if (!$arr['meta']['text']['validate']) {
         $arr['meta']['text']['validate'] = 'none';
     }
     if (!$arr['meta']['text']['length']) {
         $arr['meta']['text']['length'] = '-1';
     }
     $this->data = $arr;
     $this->meta =& $arr['meta'];
     $this->conf =& $arr['config_parsed'];
 }
开发者ID:rabe69,项目名称:mm_forum,代码行数:42,代码来源:class.tx_mmforum_userfield.php

示例12: getUserFieldData

 /**
  * Loads the record of an user field.
  * This function load the entire record of a custom user field. The
  * field's typoscript configuration is automatically parsed and the
  * array of metadata that is stored in the database is automatically
  * unserialized.
  *
  * @param  mixed $value Some data the record is to be initialized with.
  *                     This may be either the record's UID or the entire
  *                     record itself as array.
  * @return array       The record of the user field.
  *
  * @author  Martin Helmich <m.helmich@mittwald.de>
  * @version 2009-02-16
  */
 function getUserFieldData($value)
 {
     if (is_array($value)) {
         $data = $value;
     } else {
         if (MathUtility::canBeInterpretedAsInteger($value) || intval($value) != 0) {
             $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_userfields', 'uid=' . intval($value));
             if ($this->databaseHandle->sql_num_rows($res) == 0) {
                 return null;
             }
             $data = $this->databaseHandle->sql_fetch_assoc($res);
         }
     }
     /* Parse configuration TypoScript */
     $parser = $this->getTSParser();
     $parser->parse($data['config']);
     $data['config_parsed'] = $parser->setup;
     $parser->setup = array();
     $this->initializeOldMetaArray($data);
     return $data;
 }
开发者ID:rabe69,项目名称:mm_forum,代码行数:36,代码来源:class.tx_mmforum_usermanagement.php

示例13: countResult

 /**
  * Returns the number of tuples matching the query.
  *
  * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\BadConstraintException
  * @return int The number of matching tuples
  */
 public function countResult()
 {
     $parameters = array();
     $statementParts = $this->parseQuery($this->query, $parameters);
     $statementParts = $this->processStatementStructureForRecursiveMMRelation($statementParts);
     // Mmm... check if that is the right way of doing that.
     // Reset $statementParts for valid table return
     reset($statementParts);
     // if limit is set, we need to count the rows "manually" as COUNT(*) ignores LIMIT constraints
     if (!empty($statementParts['limit'])) {
         $statement = $this->buildQuery($statementParts);
         $this->replacePlaceholders($statement, $parameters, current($statementParts['tables']));
         #print $statement; exit(); // @debug
         $result = $this->databaseHandle->sql_query($statement);
         $this->checkSqlErrors($statement);
         $count = $this->databaseHandle->sql_num_rows($result);
     } else {
         $statementParts['fields'] = array('COUNT(*)');
         // having orderings without grouping is not compatible with non-MySQL DBMS
         $statementParts['orderings'] = array();
         if (isset($statementParts['keywords']['distinct'])) {
             unset($statementParts['keywords']['distinct']);
             $distinctField = $this->query->getDistinct() ? $this->query->getDistinct() : 'uid';
             $statementParts['fields'] = array('COUNT(DISTINCT ' . reset($statementParts['tables']) . '.' . $distinctField . ')');
         }
         $statement = $this->buildQuery($statementParts);
         $this->replacePlaceholders($statement, $parameters, current($statementParts['tables']));
         #print $statement; exit(); // @debug
         $result = $this->databaseHandle->sql_query($statement);
         $this->checkSqlErrors($statement);
         $count = 0;
         if ($result) {
             $row = $this->databaseHandle->sql_fetch_assoc($result);
             $count = current($row);
         }
     }
     $this->databaseHandle->sql_free_result($result);
     return (int) $count;
 }
开发者ID:BergischMedia,项目名称:vidi,代码行数:45,代码来源:VidiDbBackend.php

示例14: getIsMod

 /**
  * Determines if the user that is currently logged in is an moderator.
  *
  * @param int $forum
  * @return boolean  TRUE, if the user that is currently logged in is an moderator.
  */
 function getIsMod($forum = 0)
 {
     if ($GLOBALS['TSFE']->fe_user->user['username'] == '') {
         return false;
     }
     $userId = $this->getUserID();
     $cacheRes = $this->cache->restore("userIsMod_{$userId}_{$forum}");
     if ($cacheRes !== null) {
         return $cacheRes;
     }
     $res = $this->databaseHandle->exec_SELECTquery('c.grouprights_mod as category_auth, f.grouprights_mod as forum_auth', 'tx_mmforum_forums f LEFT JOIN tx_mmforum_forums c ON f.parentID=c.uid', 'f.uid=' . intval($forum) . ' AND f.deleted=0');
     if (!$res || $this->databaseHandle->sql_num_rows($res) == 0) {
         return false;
     }
     list($category_auth, $forum_auth) = $this->databaseHandle->sql_fetch_row($res);
     $category_auth = GeneralUtility::intExplode(',', $category_auth);
     $forum_auth = GeneralUtility::intExplode(',', $forum_auth);
     $auth = array_merge($category_auth, $forum_auth);
     $auth = array_unique($auth);
     $intersect = array_intersect($GLOBALS['TSFE']->fe_user->groupData['uid'], $auth);
     $isMod = count($intersect) > 0;
     $this->cache->store("userIsMod_{$userId}_{$forum}", $isMod);
     return $isMod;
 }
开发者ID:rabe69,项目名称:mm_forum,代码行数:30,代码来源:class.tx_mmforum_base.php

示例15: tableExists

 /**
  * @param string $tableName
  * @return bool
  */
 protected function tableExists($tableName)
 {
     $res = $this->databaseConnection->sql_query(sprintf('SHOW TABLES LIKE \'%s\'', $tableName));
     return (bool) $this->databaseConnection->sql_num_rows($res);
 }
开发者ID:steffmeister,项目名称:typo3-forum,代码行数:9,代码来源:DatabaseMigrator.php


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