本文整理汇总了PHP中PMF_Db::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_Db::getType方法的具体用法?PHP PMF_Db::getType怎么用?PHP PMF_Db::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_Db
的用法示例。
在下文中一共展示了PMF_Db::getType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllRelatedById
/**
* Returns all relevant articles for a FAQ record with the same language
*
* @param integer $record_id FAQ ID
* @param string $thema FAQ title
*
* @return string
*/
public function getAllRelatedById($record_id, $article_name, $keywords)
{
global $sids;
$relevantslisting = '';
$begriffe = str_replace('-', ' ', $article_name) . $keywords;
$search = PMF_Search_Factory::create($this->language, array('database' => PMF_Db::getType()));
$i = $last_id = 0;
$search->setDatabaseHandle($this->db)->setTable(SQLPREFIX . 'faqdata AS fd')->setResultColumns(array('fd.id AS id', 'fd.lang AS lang', 'fcr.category_id AS category_id', 'fd.thema AS thema', 'fd.content AS content'))->setJoinedTable(SQLPREFIX . 'faqcategoryrelations AS fcr')->setJoinedColumns(array('fd.id = fcr.record_id', 'fd.lang = fcr.record_lang'))->setConditions(array('fd.active' => "'yes'", 'fd.lang' => "'" . $this->language->getLanguage() . "'"))->setMatchingColumns(array('fd.thema', 'fd.content', 'fd.keywords'));
$result = $search->search($begriffe);
while (($row = $this->db->fetchObject($result)) && $i < PMF_Configuration::getInstance()->get('records.numberOfRelatedArticles')) {
if ($row->id == $record_id || $row->id == $last_id) {
continue;
}
$relevantslisting .= '' == $relevantslisting ? '<ul>' : '';
$relevantslisting .= '<li>';
$url = sprintf('%saction=artikel&cat=%d&id=%d&artlang=%s', $sids, $row->category_id, $row->id, $row->lang);
$oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . '?' . $url);
$oLink->itemTitle = $row->thema;
$oLink->text = $row->thema;
$oLink->tooltip = $row->thema;
$relevantslisting .= $oLink->toHtmlAnchor() . '</li>';
$i++;
$last_id = $row->id;
}
$relevantslisting .= $i > 0 ? '</ul>' : '';
return '' == $relevantslisting ? '-' : $relevantslisting;
}
示例2: getAllTags
/**
* Returns all tags
*
* @param string $search Move the returned result set to be the result of a start-with search
* @param integer $limit Limit the returned result set
* @param boolean $showInactive Show inactive tags
*
* @return array
*/
public function getAllTags($search = null, $limit = PMF_TAGS_CLOUD_RESULT_SET_SIZE, $showInactive = false)
{
$allTags = [];
// Hack: LIKE is case sensitive under PostgreSQL
switch (PMF_Db::getType()) {
case 'pgsql':
$like = 'ILIKE';
break;
default:
$like = 'LIKE';
break;
}
$query = sprintf("\n SELECT\n t.tagging_id AS tagging_id, t.tagging_name AS tagging_name\n FROM\n %sfaqtags t\n LEFT JOIN\n %sfaqdata_tags dt\n ON\n dt.tagging_id = t.tagging_id\n LEFT JOIN\n %sfaqdata d\n ON\n d.id = dt.record_id\n WHERE\n 1=1\n %s\n %s\n GROUP BY tagging_name\n ORDER BY tagging_name ASC", PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), $showInactive ? '' : "AND d.active = 'yes'", isset($search) && $search != '' ? "AND tagging_name " . $like . " '" . $search . "%'" : '');
$result = $this->_config->getDb()->query($query);
if ($result) {
$i = 0;
while ($row = $this->_config->getDb()->fetchObject($result)) {
if ($i < $limit) {
$allTags[$row->tagging_id] = $row->tagging_name;
} else {
break;
}
$i++;
}
}
return array_unique($allTags);
}
示例3: getAllRelatedById
/**
* Returns all relevant articles for a FAQ record with the same language
*
* @param integer $recordId FAQ ID
* @param string $question FAQ title
* @param string $keywords FAQ keywords
*
* @return array
*/
public function getAllRelatedById($recordId, $question, $keywords)
{
$terms = str_replace('-', ' ', $question) . $keywords;
$search = PMF_Search_Factory::create($this->_config, array('database' => PMF_Db::getType()));
$search->setTable(PMF_Db::getTablePrefix() . 'faqdata AS fd')->setResultColumns(array('fd.id AS id', 'fd.lang AS lang', 'fcr.category_id AS category_id', 'fd.thema AS question', 'fd.content AS answer'))->setJoinedTable(PMF_Db::getTablePrefix() . 'faqcategoryrelations AS fcr')->setJoinedColumns(array('fd.id = fcr.record_id', 'fd.lang = fcr.record_lang'))->setConditions(array('fd.active' => "'yes'", 'fd.lang' => "'" . $this->_config->getLanguage()->getLanguage() . "'"))->setMatchingColumns(array('fd.thema', 'fd.content', 'fd.keywords'));
$result = $search->search($terms);
return $this->_config->getDb()->fetchAll($result);
}
示例4: getAllRatings
/**
* Returns all ratings of FAQ records
*
* @return array
*/
public function getAllRatings()
{
$ratings = [];
switch (PMF_Db::getType()) {
case 'mssql':
case 'sqlsrv':
// In order to remove this MS SQL 2000/2005 "limit" below:
// The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or
// LIKE operator.
// we'll cast faqdata.thema datatype from text to char(2000)
// Note: the char length is simply an heuristic value
// Doing so we'll also need to trim $row->thema to remove blank chars when it is shorter than 2000 chars
$query = sprintf("\n SELECT\n fd.id AS id,\n fd.lang AS lang,\n fcr.category_id AS category_id,\n CAST(fd.thema as char(2000)) AS question,\n (fv.vote / fv.usr) AS num,\n fv.usr AS usr\n FROM\n %sfaqvoting fv,\n %sfaqdata fd\n LEFT JOIN\n %sfaqcategoryrelations fcr\n ON\n fd.id = fcr.record_id\n AND\n fd.lang = fcr.record_lang\n WHERE\n fd.id = fv.artikel\n GROUP BY\n fd.id,\n fd.lang,\n fd.active,\n fcr.category_id,\n CAST(fd.thema as char(2000)),\n fv.vote,\n fv.usr\n ORDER BY\n fcr.category_id", PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix());
break;
default:
$query = sprintf("\n SELECT\n fd.id AS id,\n fd.lang AS lang,\n fcr.category_id AS category_id,\n fd.thema AS question,\n (fv.vote / fv.usr) AS num,\n fv.usr AS usr\n FROM\n %sfaqvoting fv,\n %sfaqdata fd\n LEFT JOIN\n %sfaqcategoryrelations fcr\n ON\n fd.id = fcr.record_id\n AND\n fd.lang = fcr.record_lang\n WHERE\n fd.id = fv.artikel\n GROUP BY\n fd.id,\n fd.lang,\n fd.active,\n fcr.category_id,\n fd.thema,\n fv.vote,\n fv.usr\n ORDER BY\n fcr.category_id", PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix());
break;
}
$result = $this->_config->getDb()->query($query);
while ($row = $this->_config->getDb()->fetchObject($result)) {
$ratings[] = array('id' => $row->id, 'lang' => $row->lang, 'category_id' => $row->category_id, 'question' => $row->question, 'num' => $row->num, 'usr' => $row->usr);
}
return $ratings;
}
示例5: PMF_System
exit;
}
if ($permission['editconfig']) {
$faqSystem = new PMF_System();
?>
<header>
<h2><i class="icon-wrench"></i> <?php
echo $PMF_LANG['ad_system_info'];
?>
</h2>
</header>
<table class="table table-striped">
<tbody>
<?php
$systemInformation = array('phpMyFAQ Version' => $faqSystem->getVersion(), 'Server Software' => $_SERVER['SERVER_SOFTWARE'], 'Server Document root' => $_SERVER['DOCUMENT_ROOT'], 'phpMyFAQ installation path' => dirname(dirname($_SERVER['SCRIPT_FILENAME'])), 'PHP Version' => PHP_VERSION, 'Webserver Interface' => strtoupper(PHP_SAPI), 'PHP Extensions' => implode(', ', get_loaded_extensions()), 'PHP Session path' => session_save_path(), 'Database Server' => PMF_Db::getType(), 'Database Server Version' => $faqConfig->getDb()->serverVersion(), 'Database Client Version' => $faqConfig->getDb()->clientVersion());
foreach ($systemInformation as $name => $info) {
?>
<tr>
<td class="span3"><strong><?php
echo $name;
?>
</strong></td>
<td><?php
echo $info;
?>
</td>
</tr>
<?php
}
?>
示例6: foreach
}
}
if ($action == 'view' && is_null($searchterm)) {
$faq->getAllRecords($orderby, null, $sortby);
$laction = 'view';
$internalSearch = '';
foreach ($faq->faqRecords as $record) {
if (!isset($numActiveByCat[$record['category_id']])) {
$numActiveByCat[$record['category_id']] = 0;
}
$numActiveByCat[$record['category_id']] += $record['active'] == 'yes' ? 1 : 0;
}
} elseif ($action == "view" && !is_null($searchterm)) {
$fdTable = SQLPREFIX . 'faqdata';
$fcrTable = SQLPREFIX . 'faqcategoryrelations';
$search = PMF_Search_Factory::create($Language, array('database' => PMF_Db::getType()));
$search->setDatabaseHandle($db)->setTable($fdTable)->setResultColumns(array($fdTable . '.id AS id', $fdTable . '.lang AS lang', $fdTable . '.solution_id AS solution_id', $fcrTable . '.category_id AS category_id', $fdTable . '.sticky AS sticky', $fdTable . '.active AS active', $fdTable . '.thema AS thema', $fdTable . '.content AS content', $fdTable . '.datum AS date'))->setJoinedTable($fcrTable)->setJoinedColumns(array($fdTable . '.id = ' . $fcrTable . '.record_id', $fdTable . '.lang = ' . $fcrTable . '.record_lang'));
if (is_numeric($searchterm)) {
$search->setMatchingColumns(array($fdTable . '.solution_id'));
} else {
$search->setMatchingColumns(array($fdTable . '.thema', $fdTable . '.content', $fdTable . '.keywords'));
}
$result = $search->search($searchterm);
// @todo add missing ordering!
$laction = 'view';
$internalSearch = '&search=' . $searchterm;
$wasSearch = true;
while ($row = $db->fetchObject($result)) {
if ($searchcat != 0 && $searchcat != (int) $row->category_id) {
continue;
}
示例7: search
/**
* The main search function for the full text search
*
* @param string $searchTerm Text/Number (solution id)
* @param boolean $allLanguages true to search over all languages
*
* @return array
*/
public function search($searchTerm, $allLanguages = true)
{
$fdTable = PMF_Db::getTablePrefix() . 'faqdata';
$fcrTable = PMF_Db::getTablePrefix() . 'faqcategoryrelations';
$condition = array($fdTable . '.active' => "'yes'");
$search = PMF_Search_Factory::create($this->_config, array('database' => PMF_Db::getType()));
if (!is_null($this->getCategoryId()) && 0 < $this->getCategoryId()) {
if ($this->getCategory() instanceof PMF_Category) {
$children = $this->getCategory()->getChildNodes($this->getCategoryId());
$selectedCategory = array($fcrTable . '.category_id' => array_merge((array) $this->getCategoryId(), $children));
} else {
$selectedCategory = array($fcrTable . '.category_id' => $this->getCategoryId());
}
$condition = array_merge($selectedCategory, $condition);
}
if (!$allLanguages && !is_numeric($searchTerm)) {
$selectedLanguage = array($fdTable . '.lang' => "'" . $this->_config->getLanguage()->getLanguage() . "'");
$condition = array_merge($selectedLanguage, $condition);
}
$search->setTable($fdTable)->setResultColumns(array($fdTable . '.id AS id', $fdTable . '.lang AS lang', $fdTable . '.solution_id AS solution_id', $fcrTable . '.category_id AS category_id', $fdTable . '.thema AS question', $fdTable . '.content AS answer'))->setJoinedTable($fcrTable)->setJoinedColumns(array($fdTable . '.id = ' . $fcrTable . '.record_id', $fdTable . '.lang = ' . $fcrTable . '.record_lang'))->setConditions($condition);
if (is_numeric($searchTerm)) {
$search->setMatchingColumns(array($fdTable . '.solution_id'));
} else {
$search->setMatchingColumns(array($fdTable . '.thema', $fdTable . '.content', $fdTable . '.keywords'));
}
$result = $search->search($searchTerm);
if (!$this->_config->getDb()->numRows($result)) {
return [];
} else {
return $this->_config->getDb()->fetchAll($result);
}
}
示例8: search
/**
* The main search function for the full text search
*
* @param string $searchterm Text/Number (solution id)
* @param boolean $allLanguages true to search over all languages
*
* @return array
*/
public function search($searchterm, $allLanguages = true)
{
$fdTable = SQLPREFIX . 'faqdata';
$fcrTable = SQLPREFIX . 'faqcategoryrelations';
$condition = array($fdTable . '.active' => "'yes'");
$search = PMF_Search_Factory::create($this->language, array('database' => PMF_Db::getType()));
// Search in all or one category?
if (!is_null($this->categoryId) && 0 < $this->categoryId) {
$selectedCategory = array($fcrTable . '.category_id' => $this->categoryId);
$condition = array_merge($selectedCategory, $condition);
}
if (!$allLanguages && !is_numeric($searchterm)) {
$selectedLanguage = array($fdTable . '.lang' => "'" . $this->language->getLanguage() . "'");
$condition = array_merge($selectedLanguage, $condition);
}
$search->setDatabaseHandle($this->db)->setTable($fdTable)->setResultColumns(array($fdTable . '.id AS id', $fdTable . '.lang AS lang', $fdTable . '.solution_id AS solution_id', $fcrTable . '.category_id AS category_id', $fdTable . '.thema AS question', $fdTable . '.content AS answer'))->setJoinedTable($fcrTable)->setJoinedColumns(array($fdTable . '.id = ' . $fcrTable . '.record_id', $fdTable . '.lang = ' . $fcrTable . '.record_lang'))->setConditions($condition);
if (is_numeric($searchterm)) {
$search->setMatchingColumns(array($fdTable . '.solution_id'));
} else {
$search->setMatchingColumns(array($fdTable . '.thema', $fdTable . '.content', $fdTable . '.keywords'));
}
$result = $search->search($searchterm);
if (!$this->db->num_rows($result)) {
return array();
} else {
return $this->db->fetchAll($result);
}
}
示例9: getRecordsFromLetter
/**
* Returns all records from the current first letter
*
* @param string $letter Letter
* @return array
* @since 2007-03-30
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
public function getRecordsFromLetter($letter = 'A')
{
global $sids, $PMF_LANG;
if ($this->groupSupport) {
$permPart = sprintf("( fdg.group_id IN (%s)\n OR\n (fdu.user_id = %d AND fdg.group_id IN (%s)))", implode(', ', $this->groups), $this->user, implode(', ', $this->groups));
} else {
$permPart = sprintf("( fdu.user_id = %d OR fdu.user_id = -1 )", $this->user);
}
$letter = PMF_String::strtoupper($this->_config->getDb()->escape(PMF_String::substr($letter, 0, 1)));
$writeMap = '';
switch (PMF_Db::getType()) {
case 'sqlite':
case 'sqlite3':
$query = sprintf("\n SELECT\n fd.thema AS thema,\n fd.id AS id,\n fd.lang AS lang,\n fcr.category_id AS category_id,\n fd.content AS snap\n FROM\n %sfaqcategoryrelations fcr,\n %sfaqdata fd\n LEFT JOIN\n %sfaqdata_group AS fdg\n ON\n fd.id = fdg.record_id\n LEFT JOIN\n %sfaqdata_user AS fdu\n ON\n fd.id = fdu.record_id\n WHERE\n fd.id = fcr.record_id\n AND\n SUBSTR(fd.thema, 1, 1) = '%s'\n AND\n fd.lang = '%s'\n AND\n fd.active = 'yes'\n AND\n %s", PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), $letter, $this->_config->getLanguage()->getLanguage(), $permPart);
break;
default:
$query = sprintf("\n SELECT\n fd.thema AS thema,\n fd.id AS id,\n fd.lang AS lang,\n fcr.category_id AS category_id,\n fd.content AS snap\n FROM\n %sfaqcategoryrelations fcr,\n %sfaqdata fd\n LEFT JOIN\n %sfaqdata_group AS fdg\n ON\n fd.id = fdg.record_id\n LEFT JOIN\n %sfaqdata_user AS fdu\n ON\n fd.id = fdu.record_id\n WHERE\n fd.id = fcr.record_id\n AND\n SUBSTRING(fd.thema, 1, 1) = '%s'\n AND\n fd.lang = '%s'\n AND\n fd.active = 'yes'\n AND\n %s", PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), PMF_Db::getTablePrefix(), $letter, $this->_config->getLanguage()->getLanguage(), $permPart);
break;
}
$result = $this->_config->getDb()->query($query);
$oldId = 0;
while ($row = $this->_config->getDb()->fetchObject($result)) {
if ($oldId != $row->id) {
$title = PMF_String::htmlspecialchars($row->thema, ENT_QUOTES, 'utf-8');
$url = sprintf('%s?%saction=artikel&cat=%d&id=%d&artlang=%s', PMF_Link::getSystemRelativeUri(), $sids, $row->category_id, $row->id, $row->lang);
$oLink = new PMF_Link($url, $this->_config);
$oLink->itemTitle = $row->thema;
$oLink->text = $title;
$oLink->tooltip = $title;
$writeMap .= '<li>' . $oLink->toHtmlAnchor() . '<br />' . "\n";
$writeMap .= PMF_Utils::chopString(strip_tags($row->snap), 25) . " ...</li>\n";
}
$oldId = $row->id;
}
$writeMap = empty($writeMap) ? '' : '<ul>' . $writeMap . '</ul>';
return $writeMap;
}
示例10: foreach
$numCommentsByCat[$catkey] += $numCommentsByFaq[$faqkey];
}
}
}
if (is_null($searchTerm)) {
$faq->getAllRecords($orderBy, null, $sortBy);
foreach ($faq->faqRecords as $record) {
if (!isset($numActiveByCat[$record['category_id']])) {
$numActiveByCat[$record['category_id']] = 0;
}
$numActiveByCat[$record['category_id']] += $record['active'] == 'yes' ? 1 : 0;
}
} else {
$fdTable = PMF_Db::getTablePrefix() . 'faqdata';
$fcrTable = PMF_Db::getTablePrefix() . 'faqcategoryrelations';
$search = PMF_Search_Factory::create($faqConfig, array('database' => PMF_Db::getType()));
$search->setTable($fdTable)->setResultColumns(array($fdTable . '.id AS id', $fdTable . '.lang AS lang', $fdTable . '.solution_id AS solution_id', $fcrTable . '.category_id AS category_id', $fdTable . '.sticky AS sticky', $fdTable . '.active AS active', $fdTable . '.thema AS thema', $fdTable . '.content AS content', $fdTable . '.datum AS date'))->setJoinedTable($fcrTable)->setJoinedColumns(array($fdTable . '.id = ' . $fcrTable . '.record_id', $fdTable . '.lang = ' . $fcrTable . '.record_lang'));
if (is_numeric($searchTerm)) {
$search->setMatchingColumns(array($fdTable . '.solution_id'));
} else {
$search->setMatchingColumns(array($fdTable . '.thema', $fdTable . '.content', $fdTable . '.keywords'));
}
$result = $search->search($searchTerm);
$laction = 'view';
$internalSearch = '&search=' . $searchTerm;
$wasSearch = true;
$idsFound = array();
$faqsFound = array();
while ($row = $faqConfig->getDb()->fetchObject($result)) {
if ($searchCat != 0 && $searchCat != (int) $row->category_id) {
continue;