本文整理汇总了PHP中PMF_Db::nextID方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_Db::nextID方法的具体用法?PHP PMF_Db::nextID怎么用?PHP PMF_Db::nextID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_Db
的用法示例。
在下文中一共展示了PMF_Db::nextID方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveTags
/**
* Saves all tags from a FAQ record
*
* @param integer $record_id Record ID
* @param array $tags Array of tags
*/
public function saveTags($record_id, $tags)
{
if (!is_array($tags)) {
return false;
}
$current_tags = $this->getAllTags();
// Delete all tag references for the faq record
if (count($tags) > 0) {
$this->deleteTagsFromRecordId($record_id);
}
// Store tags and references for the faq record
foreach ($tags as $tagging_name) {
$tagging_name = trim($tagging_name);
if (PMF_String::strlen($tagging_name) > 0) {
if (!in_array(PMF_String::strtolower($tagging_name), array_map(array('PMF_String', 'strtolower'), $current_tags))) {
// Create the new tag
$new_tagging_id = $this->db->nextID(SQLPREFIX . 'faqtags', 'tagging_id');
$query = sprintf("\n INSERT INTO\n %sfaqtags\n (tagging_id, tagging_name)\n VALUES\n (%d, '%s')", SQLPREFIX, $new_tagging_id, $tagging_name);
$this->db->query($query);
// Add the tag reference for the faq record
$query = sprintf("\n INSERT INTO\n %sfaqdata_tags\n (record_id, tagging_id)\n VALUES\n (%d, %d)", SQLPREFIX, $record_id, $new_tagging_id);
$this->db->query($query);
} else {
// Add the tag reference for the faq record
$query = sprintf("\n INSERT INTO\n %sfaqdata_tags\n (record_id, tagging_id)\n VALUES\n (%d, %d)", SQLPREFIX, $record_id, array_search(PMF_String::strtolower($tagging_name), array_map(array('PMF_String', 'strtolower'), $current_tags)));
$this->db->query($query);
}
}
}
return true;
}
示例2: addComment
/**
* Adds a comment
*
* @param array $commentData Array with comment dara
* @return boolean
*/
function addComment(array $commentData)
{
$query = sprintf("\n INSERT INTO\n %sfaqcomments\n VALUES\n (%d, %d, '%s', '%s', '%s', '%s', %d, '%s')", SQLPREFIX, $this->db->nextID(SQLPREFIX . 'faqcomments', 'id_comment'), $commentData['record_id'], $commentData['type'], $commentData['username'], $commentData['usermail'], $commentData['comment'], $commentData['date'], $commentData['helped']);
if (!$this->db->query($query)) {
return false;
}
return true;
}
示例3: 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);
}
示例4: 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;
}
}
示例5: createChangeEntry
/**
* Adds a new changelog entry in the table faqchanges
*
* @param integer $id
* @param integer $userId
* @param string $text
* @param string $lang
* @param integer $revision_id
* @return boolean
* @access private
* @since 2006-08-18
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @author Matteo Scaramuccia <matteo@scaramuccia.com>
*/
function createChangeEntry($id, $userId, $text, $lang, $revision_id = 0)
{
if (!is_numeric($id) && !is_numeric($userId) && !is_string($text) && !is_string($lang)) {
return false;
}
$query = sprintf("INSERT INTO\n %sfaqchanges\n (id, beitrag, lang, revision_id, usr, datum, what)\n VALUES\n (%d, %d, '%s', %d, %d, %d, '%s')", SQLPREFIX, $this->db->nextID(SQLPREFIX . 'faqchanges', 'id'), $id, $lang, $revision_id, $userId, $_SERVER['REQUEST_TIME'], $text);
$this->db->query($query);
return true;
}
示例6: add
/**
* Add a word to the stop words dictionary.
* If the given word already exists, false is returned.
*
* @param string $word
*
* @return boolean
*/
public function add($word)
{
if (!$this->match($word)) {
$sql = "INSERT INTO {$this->table_name} VALUES(%d, '%s', '%s')";
$sql = sprintf($sql, $this->db->nextID($this->table_name, 'id'), $this->language, $word);
$this->db->query($sql);
return true;
}
return false;
}
示例7: create
/**
* Creates a new entry
*
* @param array $data Array of data
*
* @return boolean
* @throws PMF_Exception
*/
public function create(array $data)
{
if (is_null($data['id'])) {
$votingId = $this->db->nextID(SQLPREFIX . 'faqvoting', 'id');
}
$query = sprintf("\n INSERT INTO\n %sfaqvoting\n VALUES\n (%d, %d, %d, 1, %d, '%s')", SQLPREFIX, $votingId, $data['record_id'], $data['vote'], $data['date'], $data['user_ip']);
$result = $this->db->query($query);
if (!$result) {
throw new PMF_Exception($this->db->error());
}
return $result;
}
示例8: userTracking
/**
* Tracks the user and log what he did
*
* @param string $action Action string
* @param integer $id Current ID
*
* @return void
*/
public function userTracking($action, $id = 0)
{
global $sid, $user, $botBlacklist;
if (PMF_Configuration::getInstance()->get('main.enableUserTracking')) {
$bots = 0;
$banned = false;
$agent = $_SERVER['HTTP_USER_AGENT'];
$sid = PMF_Filter::filterInput(INPUT_GET, PMF_GET_KEY_NAME_SESSIONID, FILTER_VALIDATE_INT);
$sidc = PMF_Filter::filterInput(INPUT_COOKIE, PMF_COOKIE_NAME_SESSIONID, FILTER_VALIDATE_INT);
if (!is_null($sidc)) {
$sid = $sidc;
}
if ($action == 'old_session') {
$sid = null;
}
foreach ($botBlacklist as $bot) {
if ((bool) PMF_String::strstr($agent, $bot)) {
$bots++;
}
}
$network = new PMF_Network();
if (!$network->checkIp($_SERVER['REMOTE_ADDR'])) {
$banned = true;
}
if (0 == $bots && false == $banned) {
if (!isset($sid)) {
$sid = $this->db->nextID(SQLPREFIX . 'faqsessions', 'sid');
// Sanity check: force the session cookie to contains the current $sid
if (!is_null($sidc) && !$sidc != $sid) {
self::setCookie($sid);
}
$query = sprintf("\n INSERT INTO \n %sfaqsessions\n (sid, user_id, ip, time)\n VALUES\n (%d, %d, '%s', %d)", SQLPREFIX, $sid, $user ? $user->getUserId() : -1, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_TIME']);
$this->db->query($query);
}
$data = $sid . ';' . str_replace(';', ',', $action) . ';' . $id . ';' . $_SERVER['REMOTE_ADDR'] . ';' . str_replace(';', ',', $_SERVER['QUERY_STRING']) . ';' . str_replace(';', ',', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . ';' . str_replace(';', ',', urldecode($_SERVER['HTTP_USER_AGENT'])) . ';' . $_SERVER['REQUEST_TIME'] . ";\n";
$file = './data/tracking' . date('dmY');
file_put_contents($file, $data, FILE_APPEND);
}
}
}