本文整理汇总了PHP中PMF_Db::escape_string方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_Db::escape_string方法的具体用法?PHP PMF_Db::escape_string怎么用?PHP PMF_Db::escape_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_Db
的用法示例。
在下文中一共展示了PMF_Db::escape_string方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addQuestion
/**
* Adds a new question
*
* @param array $questionData
* @return boolean
* @access public
* @since 2006-09-09
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
*/
function addQuestion($questionData)
{
if (!is_array($questionData)) {
return false;
}
$query = sprintf("\n INSERT INTO\n %sfaqquestions\n VALUES\n (%d, '%s', '%s', %d, '%s', '%s', '%s')", SQLPREFIX, $this->db->nextID(SQLPREFIX . 'faqquestions', 'id'), $this->db->escape_string($questionData['ask_username']), $this->db->escape_string($questionData['ask_usermail']), $questionData['ask_category'], $this->db->escape_string($questionData['ask_content']), $questionData['ask_date'], $questionData['is_visible']);
$this->db->query($query);
return true;
}
示例2: 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->getLanguage(), $this->db->escape_string($searchterm), $date->format('Y-m-d H:i:s'));
$this->db->query($query);
}
示例3: 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->escape_string(nl2br($logText)), $_SERVER['REMOTE_ADDR']);
return $this->db->query($query);
} else {
return false;
}
}
示例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->escape_string($tagName));
$records = array();
$result = $this->db->query($query);
while ($row = $this->db->fetch_object($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->escape_string(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->escape_string(PMF_String::substr($letter, 0, 1)));
$writeMap = '';
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->fetch_object($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 = empty($writeMap) ? '' : '<ul>' . $writeMap . '</ul>';
return $writeMap;
}
示例7: addQuestion
/**
* Adds a new question
*
* @param array $questionData
*
* @return boolean
*/
function addQuestion(array $questionData)
{
$query = sprintf("\n INSERT INTO\n %sfaqquestions\n VALUES\n (%d, '%s', '%s', %d, '%s', '%s', '%s')", SQLPREFIX, $this->db->nextID(SQLPREFIX . 'faqquestions', 'id'), $this->db->escape_string($questionData['username']), $this->db->escape_string($questionData['email']), $questionData['category_id'], $this->db->escape_string($questionData['question']), date('YmdHis'), $questionData['is_visible']);
$this->db->query($query);
return true;
}