| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup BaseGeneral Base classes for modules
- * @ingroup UnaModules
- *
- * @{
- */
- /*
- * Module database queries
- */
- class BxBaseModGeneralDb extends BxDolModuleDb
- {
- protected $_oConfig;
- public function __construct(&$oConfig)
- {
- parent::__construct($oConfig);
- $this->_oConfig = $oConfig;
- }
- public function getEntriesByAuthor ($iProfileId)
- {
- $sQuery = $this->prepare ("SELECT * FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` WHERE `" . $this->_oConfig->CNF['FIELD_AUTHOR'] . "` = ?", $iProfileId);
- return $this->getAll($sQuery);
- }
- public function getEntriesNumByAuthor ($iProfileId)
- {
- $sQuery = $this->prepare ("SELECT COUNT(*) FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` WHERE `" . $this->_oConfig->CNF['FIELD_AUTHOR'] . "` = ?", $iProfileId);
- return $this->getOne($sQuery);
- }
- public function alterFulltextIndex ()
- {
- $CNF = $this->_oConfig->CNF;
- $bFulltextIndex = false;
- $aIndexes = $this->getAll("SHOW INDEXES FROM `" . $CNF['TABLE_ENTRIES'] . "`");
- foreach ($aIndexes as $r) {
- if ($CNF['TABLE_ENTRIES_FULLTEXT'] == $r['Key_name']) {
- $bFulltextIndex = true;
- break;
- }
- }
- if ($bFulltextIndex)
- $this->query("ALTER TABLE `" . $CNF['TABLE_ENTRIES'] . "` DROP INDEX `" . $CNF['TABLE_ENTRIES_FULLTEXT'] . "`");
- if (!($aFields = explode(',', getParam($CNF['PARAM_SEARCHABLE_FIELDS']))))
- return true;
- $sFields = '';
- foreach ($aFields as $s)
- $sFields .= "`$s`,";
- return $this->query("ALTER TABLE `" . $CNF['TABLE_ENTRIES'] . "` ADD FULLTEXT `" . $CNF['TABLE_ENTRIES_FULLTEXT'] . "` (" . trim($sFields, ', ') . ")");
- }
- }
- /** @} */
|