本文整理汇总了PHP中PMF_Db::escapeString方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_Db::escapeString方法的具体用法?PHP PMF_Db::escapeString怎么用?PHP PMF_Db::escapeString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_Db
的用法示例。
在下文中一共展示了PMF_Db::escapeString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logSearchTerm
/**
* Logging of search terms for improvements
*
* @param string $searchterm Search term
* @return void
*/
public function logSearchTerm($searchterm)
{
if (PMF_String::strlen($searchterm) == 0) {
return;
}
$date = new DateTime();
$query = sprintf("\n INSERT INTO\n %s\n (id, lang, searchterm, searchdate)\n VALUES\n (%d, '%s', '%s', '%s')", $this->_table, $this->db->nextID($this->_table, 'id'), $this->language, $this->db->escapeString($searchterm), $date->format('Y-m-d H:i:s'));
$this->db->query($query);
}
示例2: logAdmin
/**
* Adds a new adminlog entry
*
* @param PMF_User $user PMF_User object
* @param string $logText Logged string
*
* @return boolean
*/
public function logAdmin(PMF_User $user, $logText = '')
{
if (PMF_Configuration::getInstance()->get('main.enableAdminLog')) {
$query = sprintf("\n INSERT INTO\n %sfaqadminlog\n (id, time, usr, text, ip)\n VALUES \n (%d, %d, %d, '%s', '%s')", SQLPREFIX, $this->db->nextID(SQLPREFIX . 'faqadminlog', 'id'), $_SERVER['REQUEST_TIME'], $user->userdata->get('user_id'), $this->db->escapeString(nl2br($logText)), $_SERVER['REMOTE_ADDR']);
return $this->db->query($query);
} else {
return false;
}
}
示例3: getAllRecords
/**
* Returns an array with all data from all FAQ records
*
* @param integer $sortType Sorting type
* @param array $condition Condition
* @param string $sortOrder Sorting order
* @return void
*/
public function getAllRecords($sortType = FAQ_SORTING_TYPE_CATID_FAQID, array $condition = null, $sortOrder = 'ASC')
{
$where = '';
if (!is_null($condition)) {
$num = count($condition);
$where = 'WHERE ';
foreach ($condition as $field => $data) {
$num--;
$where .= $field;
if (is_array($data)) {
$where .= " IN (";
$separator = "";
foreach ($data as $value) {
$where .= $separator . "'" . $this->db->escapeString($value) . "'";
$separator = ", ";
}
$where .= ")";
} else {
$where .= " = '" . $this->db->escapeString($data) . "'";
}
if ($num > 0) {
$where .= " AND ";
}
}
}
$orderBy = '';
switch ($sortType) {
case FAQ_SORTING_TYPE_CATID_FAQID:
$orderBy = sprintf("\n ORDER BY\n fcr.category_id,\n fd.id %s", $sortOrder);
break;
case FAQ_SORTING_TYPE_FAQID:
$orderBy = sprintf("\n ORDER BY\n fd.id %s", $sortOrder);
break;
case FAQ_SORTING_TYPE_FAQTITLE_FAQID:
$orderBy = sprintf("\n ORDER BY\n fcr.category_id,\n fd.thema %s", $sortOrder);
break;
case FAQ_SORTING_TYPE_DATE_FAQID:
$orderBy = sprintf("\n ORDER BY\n fcr.category_id,\n fd.datum %s", $sortOrder);
break;
}
$query = sprintf("\n SELECT\n fd.id AS id,\n fd.lang AS lang,\n fcr.category_id AS category_id,\n fd.solution_id AS solution_id,\n fd.revision_id AS revision_id,\n fd.active AS active,\n fd.sticky AS sticky,\n fd.keywords AS keywords,\n fd.thema AS thema,\n fd.content AS content,\n fd.author AS author,\n fd.email AS email,\n fd.comment AS comment,\n fd.datum AS datum,\n fd.links_state AS links_state,\n fd.links_check_date AS links_check_date,\n fd.date_start AS date_start,\n fd.date_end AS date_end,\n fd.sticky AS sticky\n FROM\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 %s\n %s", SQLPREFIX, SQLPREFIX, $where, $orderBy);
$result = $this->db->query($query);
while ($row = $this->db->fetchObject($result)) {
$content = $row->content;
$active = 'yes' == $row->active;
$expired = date('YmdHis') > $row->date_end;
if (!$active) {
$content = $this->pmf_lang['err_inactiveArticle'];
}
if ($expired) {
$content = $this->pmf_lang['err_expiredArticle'];
}
$this->faqRecords[] = array('id' => $row->id, 'category_id' => $row->category_id, 'lang' => $row->lang, 'solution_id' => $row->solution_id, 'revision_id' => $row->revision_id, 'active' => $row->active, 'sticky' => $row->sticky, 'keywords' => $row->keywords, 'title' => $row->thema, 'content' => $content, 'author' => $row->author, 'email' => $row->email, 'comment' => $row->comment, 'date' => PMF_Date::createIsoDate($row->datum), 'dateStart' => $row->date_start, 'dateEnd' => $row->date_end);
}
}
示例4: getRecordsByTagName
/**
* Returns all FAQ record IDs where all tags are included
*
* @param string $tagName The name of the tag
* @return array
*/
public function getRecordsByTagName($tagName)
{
if (!is_string($tagName)) {
return false;
}
$query = sprintf("\n SELECT\n d.record_id AS record_id\n FROM\n %sfaqdata_tags d, %sfaqtags t\n WHERE\n t.tagging_id = d.tagging_id\n AND \n t.tagging_name = '%s'", SQLPREFIX, SQLPREFIX, $this->db->escapeString($tagName));
$records = array();
$result = $this->db->query($query);
while ($row = $this->db->fetchObject($result)) {
$records[] = $row->record_id;
}
return $records;
}
示例5: update
/**
* Updates all configuration items
*
* @param array $newconfig Array with new configuration values
* @return bool
*/
public function update(array $newconfig)
{
if (is_array($newconfig)) {
foreach ($newconfig as $name => $value) {
if ($name != 'main.phpMyFAQToken') {
$update = sprintf("\n UPDATE\n %sfaqconfig\n SET\n config_value = '%s'\n WHERE\n config_name = '%s'", SQLPREFIX, $this->db->escapeString(trim($value)), $name);
$this->db->query($update);
if (isset($this->config[$name])) {
unset($this->config[$name]);
}
}
}
return true;
}
return false;
}
示例6: 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->db->escapeString(PMF_String::substr($letter, 0, 1)));
$writeMap = '<ul>';
switch ($this->type) {
case 'db2':
case 'sqlite':
$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", SQLPREFIX, SQLPREFIX, SQLPREFIX, SQLPREFIX, $letter, $this->language, $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", SQLPREFIX, SQLPREFIX, SQLPREFIX, SQLPREFIX, $letter, $this->language, $permPart);
break;
}
$result = $this->db->query($query);
$oldId = 0;
while ($row = $this->db->fetchObject($result)) {
if ($oldId != $row->id) {
$title = PMF_String::htmlspecialchars($row->thema, ENT_QUOTES, 'utf-8');
$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 = $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 .= '</ul>';
return $writeMap;
}