本文整理汇总了PHP中wcf\system\WCF::getDB方法的典型用法代码示例。如果您正苦于以下问题:PHP WCF::getDB方法的具体用法?PHP WCF::getDB怎么用?PHP WCF::getDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wcf\system\WCF
的用法示例。
在下文中一共展示了WCF::getDB方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @see wcf\system\ICronjob::execute()
*/
public function execute(Cronjob $cronjob)
{
$filename = FileUtil::downloadFileFromHttp('http://www.woltlab.com/spiderlist/spiderlist.xml', 'spiders');
$xml = new XML();
$xml->load($filename);
$xpath = $xml->xpath();
// fetch spiders
$spiders = $xpath->query('/spiderlist/spider');
if (count($spiders)) {
// delete old entries
$sql = "DELETE FROM wcf" . WCF_N . "_spider";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
$statementParameters = array();
foreach ($spiders as $spider) {
$identifier = StringUtil::toLowerCase($spider->getAttribute('ident'));
$name = $xpath->query('name', $spider)->item(0);
$info = $xpath->query('info', $spider)->item(0);
$statementParameters[$identifier] = array('spiderIdentifier' => $identifier, 'spiderName' => $name->nodeValue, 'spiderURL' => $info ? $info->nodeValue : '');
}
if (!empty($statementParameters)) {
$sql = "INSERT INTO\twcf" . WCF_N . "_spider\n\t\t\t\t\t\t\t(spiderIdentifier, spiderName, spiderURL)\n\t\t\t\t\tVALUES\t\t(?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($statementParameters as $parameters) {
$statement->execute(array($parameters['spiderIdentifier'], $parameters['spiderName'], $parameters['spiderURL']));
}
}
// clear spider cache
CacheHandler::getInstance()->clear(WCF_DIR . 'cache', 'cache.spiders.php');
}
// delete tmp file
@unlink($filename);
}
示例2: getObject
/**
* Fetches a user from the database.
*/
protected function getObject()
{
$sql = "SELECT\t\tuserID, registrationDate\n\t\t\tFROM\t\twcf" . WCF_N . "_user\n\t\t\tORDER BY\tuserID ASC";
$statement = \wcf\system\WCF::getDB()->prepareStatement($sql, 1, $this->generator->numberBetween(0, $this->userCount - 1));
$statement->execute();
$this->receiver = $statement->fetchObject('\\wcf\\data\\user\\User');
}
示例3: rebuild
/**
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
protected function rebuild(array $parameters)
{
$data = array('boxes' => array(), 'pages' => array());
// load boxes
$boxList = new DashboardBoxList();
$boxList->readObjects();
foreach ($boxList as $box) {
$data['boxes'][$box->boxID] = $box;
}
// load settings
$objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.user.dashboardContainer');
$objectTypeIDs = array();
foreach ($objectTypes as $objectType) {
$objectTypeIDs[] = $objectType->objectTypeID;
}
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("objectTypeID IN (?)", array($objectTypeIDs));
$sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_dashboard_option\n\t\t\t" . $conditions . "\n\t\t\tORDER BY\tshowOrder ASC";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditions->getParameters());
while ($row = $statement->fetchArray()) {
if (!isset($data['pages'][$row['objectTypeID']])) {
$data['pages'][$row['objectTypeID']] = array();
}
$data['pages'][$row['objectTypeID']][] = $row['boxID'];
}
return $data;
}
示例4: import
/**
* @see \wcf\system\importer\IImporter::import()
*/
public function import($oldID, array $data, array $additionalData = array())
{
$data['packageID'] = 1;
// set temporary option name
$data['optionName'] = StringUtil::getRandomID();
if ($data['optionType'] == 'boolean' || $data['optionType'] == 'integer') {
if (isset($data['defaultValue'])) {
$data['defaultValue'] = intval($data['defaultValue']);
}
}
// create category
$this->createCategory($data['categoryName']);
// save option
$action = new UserOptionAction(array(), 'create', array('data' => $data));
$returnValues = $action->executeAction();
$userOption = $returnValues['returnValues'];
// update generic option name
$editor = new UserOptionEditor($userOption);
$editor->update(array('optionName' => 'option' . $userOption->optionID));
// save name
$sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_language_item\n\t\t\t\t\t\t(languageID, languageItem, languageItemValue, languageItemOriginIsSystem, languageCategoryID, packageID)\n\t\t\tVALUES\t\t\t(?, ?, ?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(LanguageFactory::getInstance()->getDefaultLanguageID(), 'wcf.user.option.option' . $userOption->optionID, $additionalData['name'], 0, $this->languageCategoryID, 1));
ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.user.option', $oldID, $userOption->optionID);
return $userOption->optionID;
}
示例5: clearLogs
/**
* Deletes the cronjob log.
*/
public static function clearLogs($packageID = PACKAGE_ID)
{
// delete logs
$sql = "DELETE FROM\twcf" . WCF_N . "_cronjob_log\n\t\t\tWHERE\t\tcronjobID IN (\n\t\t\t\t\t\tSELECT\tcronjobID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_cronjob cronjob,\n\t\t\t\t\t\t\twcf" . WCF_N . "_package_dependency package_dependency\n\t\t\t\t\t\tWHERE \tcronjob.packageID = package_dependency.dependency\n\t\t\t\t\t\t\tAND package_dependency.packageID = ?\n\t\t\t\t\t)";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($packageID);
}
示例6: enable
/**
* Enables this option.
*
* @param boolean $enable
*/
public function enable($enable = true)
{
$value = intval(!$enable);
$sql = "UPDATE\twcf" . WCF_N . "_user_option\n\t\t\tSET\tdisabled = ?\n\t\t\tWHERE\toptionID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($value, $this->optionID));
}
示例7: prepare
/**
* @see \wcf\system\like\IViewableLikeProvider::prepare()
*/
public function prepare(array $likes)
{
$responseIDs = array();
foreach ($likes as $like) {
$responseIDs[] = $like->objectID;
}
// get objects type ids
$responses = array();
$conditionBuilder = new PreparedStatementConditionBuilder();
$conditionBuilder->add('comment_response.responseID IN (?)', array($responseIDs));
$sql = "SELECT\t\tcomment.objectTypeID, comment_response.responseID\n\t\t\tFROM\t\twcf" . WCF_N . "_comment_response comment_response\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_comment comment\n\t\t\tON\t\t(comment.commentID = comment_response.commentID)\n\t\t\t" . $conditionBuilder;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditionBuilder->getParameters());
while ($row = $statement->fetchArray()) {
$responses[$row['responseID']] = $row['objectTypeID'];
}
// group likes by object type id
$likeData = array();
foreach ($likes as $like) {
if (isset($responses[$like->objectID])) {
if (!isset($likeData[$responses[$like->objectID]])) {
$likeData[$responses[$like->objectID]] = array();
}
$likeData[$responses[$like->objectID]][] = $like;
}
}
foreach ($likeData as $objectTypeID => $likes) {
$objectType = CommentHandler::getInstance()->getObjectType($objectTypeID);
if (CommentHandler::getInstance()->getCommentManager($objectType->objectType) instanceof IViewableLikeProvider) {
CommentHandler::getInstance()->getCommentManager($objectType->objectType)->prepare($likes);
}
}
}
示例8: countObjects
/**
* @see \wcf\data\DatabaseObjectList::countObjects()
*/
public function countObjects()
{
$sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\tcms" . WCF_N . "_file_to_category file_to_category,\n\t\t\t\tcms" . WCF_N . "_file file\n\t\t\t" . $this->sqlConditionJoins . "\n\t\t\t" . $this->getConditionBuilder();
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($this->getConditionBuilder()->getParameters());
return $statement->fetchColumn();
}
示例9: getData
/**
* @see wcf\system\cache\ICacheBuilder::getData()
*/
public function getData(array $cacheResource)
{
list($cache, $packageID) = explode('-', $cacheResource['cache']);
$data = array('actions' => array('user' => array(), 'admin' => array()), 'inheritedActions' => array('user' => array(), 'admin' => array()));
// get all listeners and filter options with low priority
$sql = "SELECT\t\tevent_listener.*\n\t\t\tFROM\t\twcf" . WCF_N . "_event_listener event_listener\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package_dependency package_dependency\n\t\t\tON\t\t(package_dependency.dependency = event_listener.packageID)\n\t\t\tWHERE \t\tpackage_dependency.packageID = ?\n\t\t\tORDER BY\tpackage_dependency.priority ASC";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($packageID));
while ($row = $statement->fetchArray()) {
// distinguish between inherited actions and non-inherited actions
if (!$row['inherit']) {
$data['actions'][$row['environment']][EventHandler::generateKey($row['eventClassName'], $row['eventName'])][] = $row;
} else {
if (!isset($data['inheritedActions'][$row['environment']][$row['eventClassName']])) {
$data['inheritedActions'][$row['environment']][$row['eventClassName']] = array();
}
$data['inheritedActions'][$row['environment']][$row['eventClassName']][$row['eventName']][] = $row;
}
}
// sort data by nice value and class name
foreach ($data['actions'] as &$listenerMap) {
foreach ($listenerMap as &$listeners) {
uasort($listeners, array(__CLASS__, 'sortListeners'));
}
}
foreach ($data['inheritedActions'] as &$listenerMap) {
foreach ($listenerMap as &$listeners) {
foreach ($listeners as &$val) {
uasort($val, array(__CLASS__, 'sortListeners'));
}
}
}
return $data;
}
示例10: loadVariables
/**
* Loads style-specific variables.
*/
public function loadVariables() {
if (!empty($this->variables)) {
return;
}
$sql = "SELECT variable.variableName, variable.defaultValue, value.variableValue
FROM wcf".WCF_N."_style_variable variable
LEFT JOIN wcf".WCF_N."_style_variable_value value
ON (value.variableID = variable.variableID AND value.styleID = ?)
ORDER BY variable.variableID ASC";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($this->styleID));
while ($row = $statement->fetchArray()) {
$variableName = $row['variableName'];
$variableValue = (isset($row['variableValue'])) ? $row['variableValue'] : $row['defaultValue'];
if (empty($variableValue)) {
$variableValue = '~""';
}
$this->variables[$variableName] = $variableValue;
// provide an empty value for LESS-compiler
if (empty($this->variables[$variableName])) {
$this->variables[$variableName] = "~''";
}
}
}
示例11: logFiles
/**
* @see \wcf\system\setup\IFileHandler::logFiles()
*/
public function logFiles(array $files)
{
$packageID = $this->packageInstallation->getPackageID();
// remove file extension
foreach ($files as &$file) {
$file = substr($file, 0, -4);
}
unset($file);
// get existing templates
$existingTemplates = $updateTemplateIDs = array();
$sql = "SELECT\ttemplateName, templateID\n\t\t\tFROM\twcf" . WCF_N . "_template\n\t\t\tWHERE\tpackageID = ?\n\t\t\t\tAND application = ?\n\t\t\t\tAND templateGroupID IS NULL";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($packageID, $this->application));
while ($row = $statement->fetchArray()) {
$existingTemplates[$row['templateName']] = $row['templateID'];
}
// save new templates
$sql = "INSERT INTO\twcf" . WCF_N . "_template\n\t\t\t\t\t(packageID, templateName, lastModificationTime, application)\n\t\t\tVALUES\t\t(?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($files as $file) {
if (isset($existingTemplates[$file])) {
$updateTemplateIDs[] = $existingTemplates[$file];
continue;
}
$statement->execute(array($packageID, $file, TIME_NOW, $this->application));
}
if (!empty($updateTemplateIDs)) {
// update old templates
$conditionBuilder = new PreparedStatementConditionBuilder();
$conditionBuilder->add('templateID IN (?)', array($updateTemplateIDs));
$sql = "UPDATE\twcf" . WCF_N . "_template\n\t\t\t\tSET\tlastModificationTime = ?\n\t\t\t\t" . $conditionBuilder;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array_merge(array(TIME_NOW), $conditionBuilder->getParameters()));
}
}
示例12: rebuild
/**
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
protected function rebuild(array $parameters)
{
$data = array();
// number of entry
$sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\tlinklist" . WCF_N . "_entry";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
$data['entries'] = $statement->fetchColumn();
// number of comments
$sql = "SELECT\tSUM(comments) AS count\n\t\t\tFROM\tlinklist" . WCF_N . "_entry\n\t\t\tWHERE\tcomments > 0";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
$data['comments'] = $statement->fetchColumn();
// number of authors
$sql = "SELECT\tCOUNT(DISTINCT userID) AS count\n\t\t\tFROM\tlinklist" . WCF_N . "_entry";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
$data['authors'] = $statement->fetchColumn();
// entries per day
$days = ceil((TIME_NOW - LINKLIST_INSTALL_DATE) / 86400);
if ($days <= 0) {
$days = 1;
}
$data['entriesPerDay'] = $data['entries'] / $days;
return $data;
}
示例13: fake
/**
* @see \wcf\system\faker\IFaker::fake()
*/
public function fake()
{
$likeableObjectID = $this->getLikeableObjectID();
$likeableObject = $this->objectTypeProvider->getObjectByID($likeableObjectID);
$likeableObject->setObjectType($this->objectType);
$sql = "SELECT\t\tuserID, username\n\t\t\tFROM\t\twcf" . WCF_N . "_user\n\t\t\tORDER BY\tuserID ASC";
$statement = WCF::getDB()->prepareStatement($sql, 1, $this->generator->numberBetween(0, $this->userCount - 1));
$statement->execute();
$liker = $statement->fetchObject('\\wcf\\data\\user\\User');
if (isset($this->parameters['likeValue'])) {
switch ($this->parameters['likeValue']) {
case '+':
$value = \wcf\data\like\Like::LIKE;
break;
case '-':
$value = \wcf\data\like\Like::DISLIKE;
break;
case '+-':
if ($this->generator->boolean) {
$value = \wcf\data\like\Like::LIKE;
} else {
$value = \wcf\data\like\Like::DISLIKE;
}
}
} else {
$value = \wcf\data\like\Like::LIKE;
}
\wcf\system\like\LikeHandler::getInstance()->like($likeableObject, $liker, $value);
}
示例14: getTopOptionCategories
protected function getTopOptionCategories($packageID)
{
// get all option categories and filter categories with low priority
$sql = "SELECT\t\tcategoryName, categoryID \n\t\t\tFROM\t\twcf" . WCF_N . "_option_category option_category\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package_dependency package_dependency\n\t\t\tON\t\t(package_dependency.dependency = option_category.packageID)\n\t\t\tWHERE \t\tpackage_dependency.packageID = ?\n\t\t\tORDER BY\tpackage_dependency.priority ASC";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($packageID));
$optionCategories = array();
while ($row = $statement->fetchArray()) {
$optionCategories[$row['categoryName']] = $row['categoryID'];
}
$conditions = new PreparedStatementConditionBuilder();
$conditions->add("categoryID IN (?)", array($optionCategories));
$statementParameters = $conditions->getParameters();
array_unshift($statementParameters, $packageID);
$sql = "SELECT \t\tcategoryID, parentCategoryName, categoryName,\n\t\t\t\t\t(\n\t\t\t\t\t\tSELECT COUNT(*) FROM wcf" . WCF_N . "_option WHERE categoryName = category.categoryName AND packageID IN (\n\t\t\t\t\t\t\tSELECT dependency FROM wcf" . WCF_N . "_package_dependency WHERE packageID = ?\n\t\t\t\t\t\t)\n\t\t\t\t\t) AS count\n\t\t\tFROM\t\twcf" . WCF_N . "_option_category category\n\t\t\t" . $conditions;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($statementParameters);
while ($row = $statement->fetchArray()) {
if (!isset($this->optionCategoryStructure[$row['parentCategoryName']])) {
$this->optionCategoryStructure[$row['parentCategoryName']] = array();
}
$this->optionCategoryStructure[$row['parentCategoryName']][] = $row;
}
$topOptionCategories = array();
foreach ($this->optionCategoryStructure[''] as $optionCategory) {
$count = $optionCategory['count'] + $this->countOptions($optionCategory['categoryName']);
if ($count > 0) {
$topOptionCategories[] = $optionCategory['categoryID'];
}
}
return $topOptionCategories;
}
示例15: rebuild
/**
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
protected function rebuild(array $parameters)
{
$attributes = array();
$data = array('bbcodes' => array(), 'highlighters' => array());
// get attributes
$sql = "SELECT\t\tattribute.*, bbcode.bbcodeTag\n\t\t\tFROM\t\twcf" . WCF_N . "_bbcode_attribute attribute\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_bbcode bbcode\n\t\t\tON\t\t(bbcode.bbcodeID = attribute.bbcodeID)\n\t\t\tWHERE\t\tbbcode.isDisabled = 0\n\t\t\tORDER BY\tattribute.attributeNo";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
while ($row = $statement->fetchArray()) {
if (!isset($attributes[$row['bbcodeTag']])) {
$attributes[$row['bbcodeTag']] = array();
}
$attributes[$row['bbcodeTag']][$row['attributeNo']] = new BBCodeAttribute(null, $row);
}
// get bbcodes
$sql = "SELECT\t*\n\t\t\tFROM\twcf" . WCF_N . "_bbcode\n\t\t\tWHERE\tisDisabled = 0";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
while ($row = $statement->fetchArray()) {
$row['attributes'] = isset($attributes[$row['bbcodeTag']]) ? $attributes[$row['bbcodeTag']] : array();
$data['bbcodes'][$row['bbcodeTag']] = new BBCode(null, $row);
}
// get code highlighters
$highlighters = glob(WCF_DIR . 'lib/system/bbcode/highlighter/*.class.php');
if (is_array($highlighters)) {
foreach ($highlighters as $highlighter) {
if (preg_match('~\\/([a-zA-Z]+)Highlighter\\.class\\.php$~', $highlighter, $matches)) {
$data['highlighters'][] = strtolower($matches[1]);
}
}
}
return $data;
}