本文整理汇总了PHP中wcf\system\database\util\PreparedStatementConditionBuilder::__toString方法的典型用法代码示例。如果您正苦于以下问题:PHP PreparedStatementConditionBuilder::__toString方法的具体用法?PHP PreparedStatementConditionBuilder::__toString怎么用?PHP PreparedStatementConditionBuilder::__toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wcf\system\database\util\PreparedStatementConditionBuilder
的用法示例。
在下文中一共展示了PreparedStatementConditionBuilder::__toString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
/**
* @see wcf\system\cache\ICacheBuilder::getData()
*/
public function getData(array $cacheResource)
{
// get next execution time
$conditionBuilder = new PreparedStatementConditionBuilder();
$conditionBuilder->add("packageID IN (?)", array(PackageDependencyHandler::getInstance()->getDependencies()));
$sql = "SELECT\t\tMIN(nextExec) AS nextExec,\n\t\t\t\t\tMIN(afterNextExec) AS afterNextExec\n\t\t\tFROM\t\twcf" . WCF_N . "_cronjob\n\t\t\t" . $conditionBuilder->__toString();
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditionBuilder->getParameters());
$row = $statement->fetchArray();
return array('afterNextExec' => $row['afterNextExec'], 'nextExec' => $row['nextExec']);
}
示例2: getConversationCount
/**
* Returns the number of conversations for given user.
*
* @param integer $userID
* @return integer
*/
public function getConversationCount($userID = null)
{
if ($userID === null) {
$userID = WCF::getUser()->userID;
}
if (!isset($this->conversationCount[$userID])) {
$this->conversationCount[$userID] = 0;
// load storage data
UserStorageHandler::getInstance()->loadStorage(array($userID));
// get ids
$data = UserStorageHandler::getInstance()->getStorage(array($userID), 'conversationCount');
// cache does not exist or is outdated
if ($data[$userID] === null) {
$conditionBuilder1 = new PreparedStatementConditionBuilder();
$conditionBuilder1->add('conversation_to_user.participantID = ?', array($userID));
$conditionBuilder1->add('conversation_to_user.hideConversation IN (0,1)');
$conditionBuilder2 = new PreparedStatementConditionBuilder();
$conditionBuilder2->add('conversation.userID = ?', array($userID));
$conditionBuilder2->add('conversation.isDraft = 1');
$sql = "SELECT (SELECT\tCOUNT(*)\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_conversation_to_user conversation_to_user\n\t\t\t\t\t\t" . $conditionBuilder1->__toString() . ")\n\t\t\t\t\t\t+\n\t\t\t\t\t\t(SELECT\tCOUNT(*)\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_conversation conversation\n\t\t\t\t\t\t" . $conditionBuilder2->__toString() . ") AS count";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array_merge($conditionBuilder1->getParameters(), $conditionBuilder2->getParameters()));
$row = $statement->fetchArray();
$this->conversationCount[$userID] = $row['count'];
// update storage data
UserStorageHandler::getInstance()->update($userID, 'conversationCount', serialize($this->conversationCount[$userID]));
} else {
$this->conversationCount[$userID] = unserialize($data[$userID]);
}
}
return $this->conversationCount[$userID];
}
示例3: getInnerJoin
/**
* @see \wcf\system\search\ISearchEngine::getInnerJoin()
*/
public function getInnerJoin($objectTypeName, $q, $subjectOnly = false, PreparedStatementConditionBuilder $searchIndexCondition = null, $orderBy = 'time DESC', $limit = 1000)
{
$fulltextCondition = null;
$relevanceCalc = '';
if (!empty($q)) {
$q = $this->parseSearchQuery($q);
$fulltextCondition = new PreparedStatementConditionBuilder(false);
$fulltextCondition->add("MATCH (subject" . (!$subjectOnly ? ', message, metaData' : '') . ") AGAINST (? IN BOOLEAN MODE)", array($q));
if ($orderBy == 'relevance ASC' || $orderBy == 'relevance DESC') {
$relevanceCalc = "MATCH (subject" . (!$subjectOnly ? ', message, metaData' : '') . ") AGAINST ('" . escapeString($q) . "') + (5 / (1 + POW(LN(1 + (" . TIME_NOW . " - time) / 2592000), 2))) AS relevance";
}
}
$sql = "SELECT\t\tobjectID\n\t\t\t\t\t" . ($relevanceCalc ? ',' . $relevanceCalc : '') . "\n\t\t\tFROM\t\t" . SearchIndexManager::getTableName($objectTypeName) . "\n\t\t\tWHERE\t\t" . ($fulltextCondition !== null ? $fulltextCondition : '') . "\n\t\t\t\t\t" . ($searchIndexCondition !== null && $searchIndexCondition->__toString() ? ($fulltextCondition !== null ? "AND " : '') . $searchIndexCondition : '') . "\n\t\t\t" . (!empty($orderBy) && $fulltextCondition === null ? 'ORDER BY ' . $orderBy : '') . "\n\t\t\tLIMIT\t\t" . ($limit == 1000 ? SearchEngine::INNER_SEARCH_LIMIT : $limit);
return array('fulltextCondition' => $fulltextCondition, 'searchIndexCondition' => $searchIndexCondition, 'sql' => $sql);
}
示例4: getData
/**
* @see wcf\system\cache\ICacheBuilder::getData()
*/
public function getData(array $cacheResource)
{
list($cache, $packageID, $styleID) = explode('-', $cacheResource['cache']);
$data = array();
// get active package
$activePackage = new Package($packageID);
$activePackageDir = FileUtil::getRealPath(WCF_DIR . $activePackage->packageDir);
// get package dirs
$packageDirs = array();
$conditionBuilder = new PreparedStatementConditionBuilder();
$conditionBuilder->add("dependency.packageID IN (?) AND package.packageDir <> ''", array(PackageDependencyHandler::getInstance()->getDependencies()));
$sql = "SELECT\t\tDISTINCT package.packageDir, dependency.priority\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency dependency\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\n\t\t\tON\t\t(package.packageID = dependency.dependency)\n\t\t\t" . $conditionBuilder->__toString() . "\n\t\t\tORDER BY\tdependency.priority DESC";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditionBuilder->getParameters());
while ($row = $statement->fetchArray()) {
$packageDirs[] = FileUtil::getRealPath(WCF_DIR . $row['packageDir']);
}
$packageDirs[] = FileUtil::unifyDirSeperator(WCF_DIR);
// get style icon path
$iconDirs = array();
$sql = "SELECT\tvariableValue\n\t\t\tFROM\twcf" . WCF_N . "_style_variable\n\t\t\tWHERE\tstyleID = ?\n\t\t\t\tAND variableName = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($styleID, 'global.icons.location'));
$row = $statement->fetchArray();
if (!empty($row['variableValue'])) {
$iconDirs[] = FileUtil::addTrailingSlash($row['variableValue']);
}
if (!in_array('icon/', $iconDirs)) {
$iconDirs[] = 'icon/';
}
// get icons
foreach ($packageDirs as $packageDir) {
$relativePackageDir = $activePackageDir != $packageDir ? FileUtil::getRelativePath($activePackageDir, $packageDir) : '';
foreach ($iconDirs as $iconDir) {
$path = FileUtil::addTrailingSlash($packageDir . $iconDir);
// get png icons
$icons = self::getIconFiles($path, 'png');
foreach ($icons as $icon) {
$icon = str_replace($path, '', $icon);
if (preg_match('/^(.*)(S|M|L)\\.png$/', $icon, $match)) {
if (!isset($data[$match[1]][$match[2]])) {
$data[$match[1]][$match[2]] = $relativePackageDir . $iconDir . $icon;
}
}
}
// get svg icons
$icons = self::getIconFiles($path, 'svg');
foreach ($icons as $icon) {
$icon = str_replace($path, '', $icon);
if (preg_match('/^(.*)\\.svg$/', $icon, $match)) {
if (!isset($data[$match[1]]['S'])) {
$data[$match[1]]['S'] = $relativePackageDir . $iconDir . $icon;
}
if (!isset($data[$match[1]]['M'])) {
$data[$match[1]]['M'] = $relativePackageDir . $iconDir . $icon;
}
if (!isset($data[$match[1]]['L'])) {
$data[$match[1]]['L'] = $relativePackageDir . $iconDir . $icon;
}
}
}
}
}
return $data;
}