本文整理匯總了PHP中nzedb\db\Settings::queryInsert方法的典型用法代碼示例。如果您正苦於以下問題:PHP Settings::queryInsert方法的具體用法?PHP Settings::queryInsert怎麽用?PHP Settings::queryInsert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nzedb\db\Settings
的用法示例。
在下文中一共展示了Settings::queryInsert方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getAlternate
/**
* Retrieve alternate release with same or similar searchname
*
* @param string $guid
* @param string $searchname
* @param string $userid
* @return string
*/
public function getAlternate($guid, $searchname, $userid)
{
$this->pdo->queryInsert(sprintf("INSERT IGNORE INTO dnzb_failures (userid, guid) VALUES (%d, %s)", $userid, $this->pdo->escapeString($guid)));
$rel = $this->pdo->queryOneRow(sprintf('SELECT id FROM releases WHERE guid = %s', $this->pdo->escapeString($guid)));
$this->postComment($rel['id'], $userid);
$alternate = $this->pdo->queryOneRow(sprintf('SELECT * FROM releases r
WHERE r.searchname %s
AND r.guid NOT IN (SELECT guid FROM dnzb_failures WHERE userid = %d)', $this->pdo->likeString($searchname), $userid));
return $alternate;
}
示例2: add
/**
* Add new files for a release ID.
*
* @param int $id The ID of the release.
* @param string $name Name of the file.
* @param int $size Size of the file.
* @param int $createdTime Unix time the file was created.
* @param int $hasPassword Does it have a password (see Releases class constants)?
*
* @return mixed
*/
public function add($id, $name, $size, $createdTime, $hasPassword)
{
$duplicateCheck = $this->pdo->queryOneRow(sprintf('
SELECT id
FROM release_files
WHERE releaseid = %d AND name = %s', $id, $this->pdo->escapeString(utf8_encode($name))));
if ($duplicateCheck === false) {
return $this->pdo->queryInsert(sprintf("\n\t\t\t\t\tINSERT INTO release_files\n\t\t\t\t\t(releaseid, name, size, createddate, passworded)\n\t\t\t\t\tVALUES\n\t\t\t\t\t(%d, %s, %s, %s, %d)", $id, $this->pdo->escapeString(utf8_encode($name)), $this->pdo->escapeString($size), $this->pdo->from_unixtime($createdTime), $hasPassword));
}
return 0;
}
示例3: addComment
public function addComment($id, $text, $userid, $host)
{
if ($this->pdo->getSetting('storeuserips') != "1") {
$host = "";
}
$username = $this->pdo->queryOneRow(sprintf('SELECT username FROM users WHERE id = %d', $userid));
$username = $username === false ? 'ANON' : $username['username'];
$comid = $this->pdo->queryInsert(sprintf("\n\t\t\t\tINSERT INTO release_comments (releaseid, text, user_id, createddate, host, username)\n\t\t\t\tVALUES (%d, %s, %d, NOW(), %s, %s)", $id, $this->pdo->escapeString($text), $userid, $this->pdo->escapeString($host), $this->pdo->escapeString($username)));
$this->updateReleaseCommentCount($id);
return $comid;
}
示例4: add
public function add($parentid, $userid, $subject, $message, $locked = 0, $sticky = 0, $replies = 0)
{
if ($message == "") {
return -1;
}
if ($parentid != 0) {
$par = $this->getParent($parentid);
if ($par == false) {
return -1;
}
$this->pdo->queryExec(sprintf("UPDATE forumpost SET replies = replies + 1, updateddate = NOW() WHERE id = %d", $parentid));
}
return $this->pdo->queryInsert(sprintf("\n\t\t\t\tINSERT INTO forumpost (forumid, parentid, user_id, subject, message, locked, sticky, replies, createddate, updateddate)\n\t\t\t\tVALUES (1, %d, %d, %s, %s, %d, %d, %d, NOW(), NOW())", $parentid, $userid, $this->pdo->escapeString($subject), $this->pdo->escapeString($message), $locked, $sticky, $replies));
}
示例5: insertGenre
/**
* Inserts Genre and returns last affected row (Genre ID)
*
* @param $genre
*
* @return bool
*/
private function insertGenre($genre)
{
if (isset($genre)) {
$res = $this->pdo->queryInsert(sprintf("INSERT INTO genres (title, type, disabled) VALUES (%s ,%d ,%d)", $this->pdo->escapeString($genre), 6000, 0));
return $res;
}
}
示例6: getAlternate
/**
* Retrieve alternate release with same or similar searchname
*
* @param string $guid
* @param string $userid
* @return string
*/
public function getAlternate($guid, $userid)
{
$rel = $this->pdo->queryOneRow(sprintf('
SELECT id, searchname, categoryid
FROM releases
WHERE guid = %s', $this->pdo->escapeString($guid)));
if ($rel === false) {
return false;
}
$insert = $this->pdo->queryInsert(sprintf('
INSERT IGNORE INTO dnzb_failures (release_id, userid, failed)
VALUES (%d, %d, 1)', $rel['id'], $userid));
// If we didn't actually insert the row, don't add a comment
if (is_numeric($insert) && $insert > 0) {
$this->postComment($rel['id'], $userid);
}
$alternate = $this->pdo->queryOneRow(sprintf('
SELECT r.guid
FROM releases r
LEFT JOIN dnzb_failures df ON r.id = df.release_id
WHERE r.searchname %s
AND df.release_id IS NULL
AND r.categoryid = %d
AND r.id != %d
ORDER BY r.postdate DESC', $this->pdo->likeString($rel['searchname'], true, true), $rel['categoryid'], $rel['id']));
return $alternate;
}
示例7: addBulk
/**
* Update the list of newsgroups and return an array of messages.
*
* @param string $groupList
* @param int $active
* @param int $backfill
*
* @return array
*/
public function addBulk($groupList, $active = 1, $backfill = 1)
{
if (preg_match('/^\\s*$/m', $groupList)) {
$ret = "No group list provided.";
} else {
$nntp = new NNTP(['Echo' => false]);
if ($nntp->doConnect() !== true) {
return 'Problem connecting to usenet.';
}
$groups = $nntp->getGroups();
$nntp->doQuit();
if ($nntp->isError($groups)) {
return 'Problem fetching groups from usenet.';
}
$regFilter = '/' . $groupList . '/i';
$ret = [];
foreach ($groups as $group) {
if (preg_match($regFilter, $group['group']) > 0) {
$res = $this->pdo->queryOneRow(sprintf('SELECT id FROM groups WHERE name = %s', $this->pdo->escapeString($group['group'])));
if ($res === false) {
$this->pdo->queryInsert(sprintf('INSERT INTO groups (name, active, backfill) VALUES (%s, %d, %d)', $this->pdo->escapeString($group['group']), $active, $backfill));
$ret[] = ['group' => $group['group'], 'msg' => 'Created'];
}
}
}
if (count($ret) === 0) {
$ret = 'No groups found with your regex, try again!';
}
}
return $ret;
}
示例8: update
/**
* Update movie on movie-edit page.
*
* @param array $values Array of keys/values to update. See $validKeys
* @return int|bool
*/
public function update(array $values)
{
if (!count($values)) {
return false;
}
$validKeys = $this->getColumnKeys();
$query = ['0' => 'INSERT INTO movieinfo (updateddate, createddate, ', '1' => ' VALUES (NOW(), NOW(), ', '2' => 'ON DUPLICATE KEY UPDATE updateddate = NOW(), '];
$found = 0;
foreach ($values as $key => $value) {
if (in_array($key, $validKeys) && !empty($value)) {
$found++;
$query[0] .= "{$key}, ";
if (in_array($key, ['genre', 'language'])) {
$value = substr($value, 0, 64);
}
$value = $this->pdo->escapeString($value);
$query[1] .= "{$value}, ";
$query[2] .= "{$key} = {$value}, ";
}
}
if (!$found) {
return false;
}
foreach ($query as $key => $value) {
$query[$key] = rtrim($value, ', ');
}
return $this->pdo->queryInsert($query[0] . ') ' . $query[1] . ') ' . $query[2]);
}
示例9: getAlternate
/**
* Retrieve alternate release with same or similar searchname
*
* @param string $guid
* @param string $searchname
* @param string $userid
* @return string
*/
public function getAlternate($guid, $searchname, $userid)
{
$rel = $this->pdo->queryOneRow(sprintf('
SELECT id, categoryid
FROM releases
WHERE guid = %s', $this->pdo->escapeString($guid)));
// Specifying LAST_INSERT_ID on releaseid will return the releaseid
// if the row was actually inserted and not updated
$insert = $this->pdo->queryInsert(sprintf('
INSERT INTO dnzb_failures (release_id, userid, failed)
VALUES (LAST_INSERT_ID(%d), %d, 1)
ON DUPLICATE KEY UPDATE failed = failed + 1', $rel['id'], $userid));
// If we didn't actually insert the row, don't add a comment
if ((int) $insert > 0) {
$this->postComment($rel['id'], $userid);
}
$alternate = $this->pdo->queryOneRow(sprintf('
SELECT r.*
FROM releases r
LEFT JOIN dnzb_failures df ON r.id = df.release_id
WHERE r.searchname %s
AND df.release_id IS NULL
AND r.categoryid = %d', $this->pdo->likeString($searchname, true, true), $rel['categoryid'], $userid));
return $alternate;
}
示例10: insertAniDBEpisodes
/**
* Inserts new anime info from AniDB to anidb table
*
* @param array $episodeArr
*/
private function insertAniDBEpisodes(array $episodeArr = [])
{
if (!empty($episodeArr)) {
foreach ($episodeArr as $episode) {
$this->pdo->queryInsert(sprintf('
INSERT IGNORE INTO anidb_episodes (anidbid, episodeid, episode_no, episode_title, airdate)
VALUES (%d, %d, %d, %s, %s)', $this->anidbId, $episode['episode_id'], $episode['episode_no'], $this->pdo->escapeString($episode['episode_title']), $this->pdo->escapeString($episode['airdate'])));
}
}
}
示例11: getAlternate
/**
* Retrieve alternate release with same or similar searchname
*
* @param string $guid
* @param string $searchname
* @param string $userid
* @return string
*/
public function getAlternate($guid, $searchname, $userid)
{
//status values
// 0/false = successfully downloaded
// 1/true = failed download
$this->pdo->queryInsert(sprintf("INSERT IGNORE INTO dnzb_failures (userid, guid) VALUES (%d, %s)", $userid, $this->pdo->escapeString($guid)));
$alternate = $this->pdo->queryOneRow(sprintf('SELECT * FROM releases r
WHERE r.searchname %s
AND r.guid NOT IN (SELECT guid FROM failed_downloads WHERE userid = %d)', $this->pdo->likeString($searchname), $userid));
return $alternate;
}
示例12: addAliases
/**
* Inserts aliases for videos
*
* @param $videoId
* @param array $aliases
*/
public function addAliases($videoId, array $aliases = [])
{
if (!empty($aliases) && $videoId > 0) {
foreach ($aliases as $key => $title) {
// Check for tvmaze style aka
if (is_array($title) && !empty($title['name'])) {
$title = $title['name'];
}
// Check if we have the AKA already
$check = $this->getAliases(0, $title);
if ($check === false) {
$this->pdo->queryInsert(sprintf('
INSERT IGNORE INTO videos_aliases
(videos_id, title)
VALUES (%d, %s)', $videoId, $this->pdo->escapeString($title)));
}
}
}
}
示例13: _updateConsoleTable
/**
* @param array $con
*
* @return false|int|string
*/
protected function _updateConsoleTable($con = [])
{
$ri = new ReleaseImage($this->pdo);
$check = $this->pdo->queryOneRow(sprintf('
SELECT id
FROM consoleinfo
WHERE asin = %s', $this->pdo->escapeString($con['asin'])));
if ($check === false) {
$consoleId = $this->pdo->queryInsert(sprintf("INSERT INTO consoleinfo (title, asin, url, salesrank, platform, publisher, genre_id, esrb, releasedate, review, cover, createddate, updateddate)\n\t\t\t\t\tVALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, NOW(), NOW())", $this->pdo->escapeString($con['title']), $this->pdo->escapeString($con['asin']), $this->pdo->escapeString($con['url']), $con['salesrank'], $this->pdo->escapeString($con['platform']), $this->pdo->escapeString($con['publisher']), $con['consolegenreID'] == -1 ? "null" : $con['consolegenreID'], $this->pdo->escapeString($con['esrb']), $con['releasedate'] != "" ? $this->pdo->escapeString($con['releasedate']) : "null", $this->pdo->escapeString(substr($con['review'], 0, 3000)), $con['cover']));
if ($con['cover'] === 1) {
$con['cover'] = $ri->saveImage($consoleId, $con['coverurl'], $this->imgSavePath, 250, 250);
}
} else {
$consoleId = $check['id'];
if ($con['cover'] === 1) {
$con['cover'] = $ri->saveImage($consoleId, $con['coverurl'], $this->imgSavePath, 250, 250);
}
$this->update($consoleId, $con['title'], $con['asin'], $con['url'], $con['salesrank'], $con['platform'], $con['publisher'], isset($con['releasedate']) ? $con['releasedate'] : null, $con['esrb'], $con['cover'], $con['consolegenreID'], isset($con['review']) ? $con['review'] : null);
}
return $consoleId;
}
示例14: addShow
/**
* When a user wants to add a show to "my shows" insert it into the user series table.
*
* @param int $uID ID of user.
* @param int $rageID Rage ID of tv show.
* @param array $catID List of category ID's
*
* @return bool|int
*/
public function addShow($uID, $rageID, $catID = array())
{
return $this->pdo->queryInsert(sprintf("INSERT INTO userseries (user_id, rageid, categoryid, createddate) VALUES (%d, %d, %s, NOW())", $uID, $rageID, !empty($catID) ? $this->pdo->escapeString(implode('|', $catID)) : "NULL"));
}
示例15: updateMovieInfo
/**
* Fetch IMDB/TMDB info for the movie.
*
* @param string $imdbId
*
* @return bool
*/
public function updateMovieInfo($imdbId)
{
if ($this->echooutput && $this->service !== '') {
$this->pdo->log->doEcho($this->pdo->log->primary("Fetching IMDB info from TMDB using IMDB ID: " . $imdbId));
}
// Check TMDB for IMDB info.
$tmdb = $this->fetchTMDBProperties($imdbId);
// Check IMDB for movie info.
$imdb = $this->fetchIMDBProperties($imdbId);
if (!$imdb && !$tmdb) {
return false;
}
// Check FanArt.tv for background images.
$fanart = $this->fetchFanartTVProperties($imdbId);
$mov = [];
$mov['cover'] = $mov['backdrop'] = $movieID = 0;
$mov['type'] = $mov['director'] = $mov['actors'] = $mov['language'] = '';
$mov['imdb_id'] = $imdbId;
$mov['tmdb_id'] = !isset($tmdb['tmdb_id']) || $tmdb['tmdb_id'] == '' ? 'NULL' : $tmdb['tmdb_id'];
// Prefer FanArt.tv cover over TMDB. And TMDB over IMDB.
if ($this->checkVariable($fanart['cover'])) {
$mov['cover'] = $this->releaseImage->saveImage($imdbId . '-cover', $fanart['cover'], $this->imgSavePath);
} else {
if ($this->checkVariable($tmdb['cover'])) {
$mov['cover'] = $this->releaseImage->saveImage($imdbId . '-cover', $tmdb['cover'], $this->imgSavePath);
} else {
if ($this->checkVariable($imdb['cover'])) {
$mov['cover'] = $this->releaseImage->saveImage($imdbId . '-cover', $imdb['cover'], $this->imgSavePath);
}
}
}
// Backdrops.
if ($this->checkVariable($fanart['backdrop'])) {
$mov['backdrop'] = $this->releaseImage->saveImage($imdbId . '-backdrop', $fanart['backdrop'], $this->imgSavePath, 1920, 1024);
} else {
if ($this->checkVariable($tmdb['backdrop'])) {
$mov['backdrop'] = $this->releaseImage->saveImage($imdbId . '-backdrop', $tmdb['backdrop'], $this->imgSavePath, 1920, 1024);
}
}
$mov['title'] = $this->setTmdbImdbVar($imdb['title'], $tmdb['title']);
$mov['rating'] = $this->setTmdbImdbVar($imdb['rating'], $tmdb['rating']);
$mov['plot'] = $this->setTmdbImdbVar($imdb['plot'], $tmdb['plot']);
$mov['tagline'] = $this->setTmdbImdbVar($imdb['tagline'], $tmdb['tagline']);
$mov['year'] = $this->setTmdbImdbVar($imdb['year'], $tmdb['year']);
$mov['genre'] = $this->setTmdbImdbVar($imdb['genre'], $tmdb['genre']);
if ($this->checkVariable($imdb['type'])) {
$mov['type'] = $imdb['type'];
}
if ($this->checkVariable($imdb['director'])) {
$mov['director'] = is_array($imdb['director']) ? implode(', ', array_unique($imdb['director'])) : $imdb['director'];
}
if ($this->checkVariable($imdb['actors'])) {
$mov['actors'] = is_array($imdb['actors']) ? implode(', ', array_unique($imdb['actors'])) : $imdb['actors'];
}
if ($this->checkVariable($imdb['language'])) {
$mov['language'] = is_array($imdb['language']) ? implode(', ', array_unique($imdb['language'])) : $imdb['language'];
}
if (is_array($mov['genre'])) {
$mov['genre'] = implode(', ', array_unique($mov['genre']));
}
if (is_array($mov['type'])) {
$mov['type'] = implode(', ', array_unique($mov['type']));
}
$mov['title'] = html_entity_decode($mov['title'], ENT_QUOTES, 'UTF-8');
$mov['plot'] = html_entity_decode(preg_replace('/\\s+See full summary »/', ' ', $mov['plot']), ENT_QUOTES, 'UTF-8');
$mov['tagline'] = html_entity_decode($mov['tagline'], ENT_QUOTES, 'UTF-8');
$mov['genre'] = html_entity_decode($mov['genre'], ENT_QUOTES, 'UTF-8');
$mov['director'] = html_entity_decode($mov['director'], ENT_QUOTES, 'UTF-8');
$mov['actors'] = html_entity_decode($mov['actors'], ENT_QUOTES, 'UTF-8');
$mov['language'] = html_entity_decode($mov['language'], ENT_QUOTES, 'UTF-8');
$mov['type'] = html_entity_decode(ucwords(preg_replace('/[\\.\\_]/', ' ', $mov['type'])), ENT_QUOTES, 'UTF-8');
$mov['title'] = str_replace(['/', '\\'], '', $mov['title']);
$movieID = $this->pdo->queryInsert(sprintf("\n\t\t\t\tINSERT INTO movieinfo\n\t\t\t\t\t(imdbid, tmdbid, title, rating, tagline, plot, year, genre, type,\n\t\t\t\t\tdirector, actors, language, cover, backdrop, createddate, updateddate)\n\t\t\t\tVALUES\n\t\t\t\t\t(%d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %d, NOW(), NOW())\n\t\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\t\timdbid = %d, tmdbid = %s, title = %s, rating = %s, tagline = %s, plot = %s, year = %s, genre = %s,\n\t\t\t\t\ttype = %s, director = %s, actors = %s, language = %s, cover = %d, backdrop = %d, updateddate = NOW()", $mov['imdb_id'], $mov['tmdb_id'], $this->pdo->escapeString($mov['title']), $this->pdo->escapeString($mov['rating']), $this->pdo->escapeString($mov['tagline']), $this->pdo->escapeString($mov['plot']), $this->pdo->escapeString($mov['year']), $this->pdo->escapeString(substr($mov['genre'], 0, 64)), $this->pdo->escapeString($mov['type']), $this->pdo->escapeString($mov['director']), $this->pdo->escapeString($mov['actors']), $this->pdo->escapeString(substr($mov['language'], 0, 64)), $mov['cover'], $mov['backdrop'], $mov['imdb_id'], $mov['tmdb_id'], $this->pdo->escapeString($mov['title']), $this->pdo->escapeString($mov['rating']), $this->pdo->escapeString($mov['tagline']), $this->pdo->escapeString($mov['plot']), $this->pdo->escapeString($mov['year']), $this->pdo->escapeString(substr($mov['genre'], 0, 64)), $this->pdo->escapeString($mov['type']), $this->pdo->escapeString($mov['director']), $this->pdo->escapeString($mov['actors']), $this->pdo->escapeString(substr($mov['language'], 0, 64)), $mov['cover'], $mov['backdrop']));
if ($this->echooutput && $this->service !== '') {
$this->pdo->log->doEcho($this->pdo->log->headerOver($movieID !== 0 ? 'Added/updated movie: ' : 'Nothing to update for movie: ') . $this->pdo->log->primary($mov['title'] . ' (' . $mov['year'] . ') - ' . $mov['imdb_id']));
}
return $movieID === 0 ? false : true;
}