本文整理汇总了PHP中newznab\db\Settings::queryInsert方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::queryInsert方法的具体用法?PHP Settings::queryInsert怎么用?PHP Settings::queryInsert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类newznab\db\Settings
的用法示例。
在下文中一共展示了Settings::queryInsert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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)
{
$insert = 0;
$duplicateCheck = $this->pdo->queryOneRow(sprintf('
SELECT id
FROM releasefiles
WHERE releaseid = %d AND name = %s', $id, $this->pdo->escapeString(utf8_encode($name))));
if ($duplicateCheck === false) {
$insert = $this->pdo->queryInsert(sprintf("\n\t\t\t\t\t\tINSERT INTO releasefiles\n\t\t\t\t\t\t(releaseid, name, size, createddate, passworded)\n\t\t\t\t\t\tVALUES\n\t\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 $insert;
}
示例2: add
/**
* Add a forum post.
*/
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));
}
$this->pdo->queryInsert(sprintf("INSERT INTO forumpost (forumid, parentid, userid, subject, message, locked, sticky, replies, createddate, updateddate) VALUES ( 1, %d, %d, %s, %s, %d, %d, %d,NOW(), NOW())", $parentid, $userid, $this->pdo->escapeString($subject), $this->pdo->escapeString($message), $locked, $sticky, $replies));
}
示例3: addBulk
/**
* Update the list of newsgroups from nntp provider matching a regex and return an array of messages.
*/
function addBulk($groupList, $active = 1, $backfill = 1)
{
$ret = array();
if ($groupList == "") {
$ret[] = "No group list provided.";
} else {
$nntp = new NNTP(['Echo' => false]);
if (!$nntp->doConnect()) {
$ret[] = "Failed to get NNTP connection";
return $ret;
}
$groups = $nntp->getGroups();
$nntp->doQuit();
$regfilter = "/(" . str_replace(array('.', '*'), array('\\.', '.*?'), $groupList) . ")\$/";
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) {
$this->pdo->queryExec(sprintf("update groups SET active = %d where id = %d", $active, $res["id"]));
$ret[] = array('group' => $group['group'], 'msg' => 'Updated');
} else {
$desc = "";
$this->pdo->queryInsert(sprintf("INSERT INTO groups (name, description, active, backfill) VALUES (%s, %s, %d, %s)", $this->pdo->escapeString($group['group']), $this->pdo->escapeString($desc), $active, $backfill));
$ret[] = array('group' => $group['group'], 'msg' => 'Created');
}
}
}
}
return $ret;
}
示例4: addMovie
public function addMovie($uid, $imdbid, $catid = array())
{
$db = new Settings();
$catid = !empty($catid) ? $db->escapeString(implode('|', $catid)) : "null";
$sql = sprintf("insert into usermovies (userid, imdbid, categoryid, createddate) values (%d, %d, %s, now())", $uid, $imdbid, $catid);
return $db->queryInsert($sql);
}
示例5: addFull
public function addFull($id, $xml)
{
$row = $this->getFull($id);
if ($row) {
return -1;
}
return $this->pdo->queryInsert(sprintf("INSERT INTO releaseextrafull (releaseid, mediainfo) VALUES (%d, %s)", $id, $this->pdo->escapeString($xml)));
}
示例6: insertGenre
/**
* Inserts Genre and returns last affected row (Genre id)
*
* @param $genre
*
* @return bool
*/
private function insertGenre($genre)
{
$res = '';
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;
}
示例7: 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'])));
}
}
}
示例8: 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;
}
示例9: addComment
/**
* Add a release_comments row.
*/
public function addComment($id, $gid, $text, $userid, $host)
{
if (strlen(trim($text)) == 0) {
return false;
}
if ($this->pdo->getSetting('storeuserips') != "1") {
$host = "";
}
$comid = $this->pdo->queryInsert(sprintf("INSERT INTO release_comments (releaseid, gid, text, userid, createddate, host) VALUES (%d, %s, %s, %d, now(), %s)", $id, $this->pdo->escapeString($gid), $this->pdo->escapeString($text), $userid, $this->pdo->escapeString($host)));
$this->updateReleaseCommentCount($gid);
return $comid;
}
示例10: addUpdateMusicInfo
/**
* Insert or update a musicinfo row.
*/
public function addUpdateMusicInfo($title, $asin, $url, $salesrank, $artist, $publisher, $releasedate, $review, $year, $genreID, $tracks, $cover)
{
if (strlen($year) > 4) {
if (preg_match("/\\d{4}/", $year, $matches)) {
$year = $this->pdo->escapeString($matches[0]);
} else {
$year = "null";
}
} else {
$year = $this->pdo->escapeString($year);
}
$sql = sprintf("\n\t\tINSERT INTO musicinfo (title, asin, url, salesrank, artist, publisher, releasedate, review, year, genreID, tracks, cover, createddate, updateddate)\n\t\tVALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, now(), now())\n\t\t\tON DUPLICATE KEY UPDATE title = %s, asin = %s, url = %s, salesrank = %s, artist = %s, publisher = %s, releasedate = %s, review = %s, year = %s, genreID = %s, tracks = %s, cover = %d, createddate = now(), updateddate = now()", $this->pdo->escapeString($title), $this->pdo->escapeString($asin), $this->pdo->escapeString($url), $salesrank, $this->pdo->escapeString($artist), $this->pdo->escapeString($publisher), $releasedate, $this->pdo->escapeString($review), $year, $genreID == -1 ? "null" : $genreID, $this->pdo->escapeString($tracks), $cover, $this->pdo->escapeString($title), $this->pdo->escapeString($asin), $this->pdo->escapeString($url), $salesrank, $this->pdo->escapeString($artist), $this->pdo->escapeString($publisher), $releasedate, $this->pdo->escapeString($review), $this->pdo->escapeString($year), $genreID == -1 ? "null" : $genreID, $this->pdo->escapeString($tracks), $cover);
$musicId = $this->pdo->queryInsert($sql);
return $musicId;
}
示例11: add
/**
* Add a releaseregex row.
*
* @param $regex
*
* @return bool|int
*/
public function add($regex)
{
$groupname = $regex["groupname"];
if ($groupname == "") {
$groupname = "null";
} else {
$groupname = sprintf("%s", $this->pdo->escapeString($regex["groupname"]));
}
$catid = $regex["category"];
if ($catid == "-1") {
$catid = "null";
} else {
$catid = sprintf("%d", $regex["category"]);
}
return $this->pdo->queryInsert(sprintf("insert into releaseregex (groupname, regex, ordinal, status, description, categoryid) values (%s, %s, %d, %d, %s, %s) ", $groupname, $this->pdo->escapeString($regex["regex"]), $regex["ordinal"], $regex["status"], $this->pdo->escapeString($regex["description"]), $catid));
}
示例12: addUpdateBookInfo
/**
* Insert or update a bookinfo row.
*/
public function addUpdateBookInfo($title, $asin, $url, $author, $publisher, $publishdate, $review, $cover, $dewey, $ean, $isbn, $pages)
{
if ($pages == 0) {
$pages = "null";
} else {
$pages = $pages + 0;
}
if ($publishdate == "") {
$publishdate = "null";
} elseif (strlen($publishdate) == 4) {
$publishdate = $this->pdo->escapeString($publishdate . "-01-01");
} elseif (strlen($publishdate) == 7) {
$publishdate = $this->pdo->escapeString($publishdate . "-01");
} else {
$publishdate = $this->pdo->escapeString($publishdate);
}
$sql = sprintf("INSERT INTO bookinfo (title, asin, url, author, publisher, publishdate, review, cover, createddate, updateddate, dewey, ean, isbn, pages)\n\t\tVALUES (%s, %s, %s, %s, %s, %s, %s, %d, now(), now(), %s, %s, %s, %s)\n\t\t\tON DUPLICATE KEY UPDATE title = %s, asin = %s, url = %s, author = %s, publisher = %s, publishdate = %s, review = %s, cover = %d, createddate = now(), updateddate = now(), dewey = %s, ean = %s, isbn = %s, pages = %s", $this->pdo->escapeString($title), $this->pdo->escapeString($asin), $this->pdo->escapeString($url), $this->pdo->escapeString($author), $this->pdo->escapeString($publisher), $publishdate, $this->pdo->escapeString($review), $cover, $this->pdo->escapeString($dewey), $this->pdo->escapeString($ean), $this->pdo->escapeString($isbn), $pages, $this->pdo->escapeString($title), $this->pdo->escapeString($asin), $this->pdo->escapeString($url), $this->pdo->escapeString($author), $this->pdo->escapeString($publisher), $this->pdo->escapeString($publishdate), $this->pdo->escapeString($review), $cover, $this->pdo->escapeString($dewey), $this->pdo->escapeString($ean), $this->pdo->escapeString($isbn), $pages);
$bookId = $this->pdo->queryInsert($sql);
return $bookId;
}
示例13: _updateConsoleTable
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, genreid, 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: processNfoFiles
/**
* Attempt to find NFO files inside the NZB's of releases.
*
* @param object $nntp Instance of class NNTP.
* @param string $groupID (optional) Group id.
* @param string $guidChar (optional) First character of the release GUID (used for multi-processing).
* @param int $processImdb (optional) Attempt to find IMDB id's in the NZB?
* @param int $processTvrage (optional) Attempt to find TvRage id's in the NZB?
*
* @return int How many NFO's were processed?
*
* @access public
*/
public function processNfoFiles($nntp, $groupID = '', $guidChar = '', $processImdb = 1, $processTvrage = 1)
{
$ret = 0;
$guidCharQuery = $guidChar === '' ? '' : 'AND r.guid ' . $this->pdo->likeString($guidChar, false, true);
$groupIDQuery = $groupID === '' ? '' : 'AND r.groupid = ' . $groupID;
$optionsQuery = self::NfoQueryString($this->pdo);
$res = $this->pdo->query(sprintf('
SELECT r.id, r.guid, r.groupid, r.name
FROM releases r
WHERE 1=1 %s %s %s
ORDER BY r.nfostatus ASC, r.postdate DESC
LIMIT %d', $optionsQuery, $guidCharQuery, $groupIDQuery, $this->nzbs));
$nfoCount = count($res);
if ($nfoCount > 0) {
$this->pdo->log->doEcho($this->pdo->log->primary(PHP_EOL . ($guidChar === '' ? '' : '[' . $guidChar . '] ') . ($groupID === '' ? '' : '[' . $groupID . '] ') . 'Processing ' . $nfoCount . ' NFO(s), starting at ' . $this->nzbs . ' * = hidden NFO, + = NFO, - = no NFO, f = download failed.'));
if ($this->echo) {
// Get count of releases per nfo status
$nfoStats = $this->pdo->queryDirect(sprintf('
SELECT r.nfostatus AS status, COUNT(*) AS count
FROM releases r
WHERE 1=1 %s %s %s
GROUP BY r.nfostatus
ORDER BY r.nfostatus ASC', $optionsQuery, $guidCharQuery, $groupIDQuery));
if ($nfoStats instanceof Traversable) {
$outString = PHP_EOL . 'Available to process';
foreach ($nfoStats as $row) {
$outString .= ', ' . $row['status'] . ' = ' . number_format($row['count']);
}
$this->pdo->log->doEcho($this->pdo->log->header($outString . '.'));
}
}
$groups = new Groups(['Settings' => $this->pdo]);
$nzbContents = new NZBContents(['Echo' => $this->echo, 'NNTP' => $nntp, 'Nfo' => $this, 'Settings' => $this->pdo, 'PostProcess' => new PostProcess(['Echo' => $this->echo, 'Nfo' => $this, 'Settings' => $this->pdo])]);
$movie = new Movie(['Echo' => $this->echo, 'Settings' => $this->pdo]);
$tvRage = new TvRage(['Echo' => $this->echo, 'Settings' => $this->pdo]);
foreach ($res as $arr) {
$fetchedBinary = $nzbContents->getNFOfromNZB($arr['guid'], $arr['id'], $arr['groupid'], $groups->getByNameByID($arr['groupid']));
if ($fetchedBinary !== false) {
// Insert nfo into database.
$cp = 'COMPRESS(%s)';
$nc = $this->pdo->escapeString($fetchedBinary);
$ckreleaseid = $this->pdo->queryOneRow(sprintf('SELECT id FROM releasenfo WHERE releaseid = %d', $arr['id']));
if (!isset($ckreleaseid['id'])) {
$this->pdo->queryInsert(sprintf('INSERT INTO releasenfo (nfo, releaseid) VALUES (' . $cp . ', %d)', $nc, $arr['id']));
}
$this->pdo->queryExec(sprintf('UPDATE releases SET nfostatus = %d WHERE id = %d', self::NFO_FOUND, $arr['id']));
$ret++;
$movie->doMovieUpdate($fetchedBinary, 'nfo', $arr['id'], $processImdb);
// If set scan for tvrage info.
if ($processTvrage == 1) {
$rageId = $this->parseRageId($fetchedBinary);
if ($rageId !== false) {
$show = $tvRage->parseNameEpSeason($arr['name']);
if (is_array($show) && $show['name'] != '') {
// Update release with season, ep, and air date info (if available) from release title.
$tvRage->updateEpInfo($show, $arr['id']);
$rid = $tvRage->getByRageID($rageId);
if (!$rid) {
$tvrShow = $tvRage->getRageInfoFromService($rageId);
$tvRage->updateRageInfo($rageId, $show, $tvrShow, $arr['id']);
}
}
}
}
}
}
}
// Remove nfo that we cant fetch after 5 attempts.
$releases = $this->pdo->queryDirect(sprintf('SELECT r.id
FROM releases r
WHERE r.nzbstatus = %d
AND r.nfostatus < %d %s %s', NZB::NZB_ADDED, $this->maxRetries, $groupIDQuery, $guidCharQuery));
if ($releases instanceof Traversable) {
foreach ($releases as $release) {
$this->pdo->queryExec(sprintf('DELETE FROM releasenfo WHERE nfo IS NULL AND releaseid = %d', $release['id']));
}
}
// Set releases with no NFO.
$this->pdo->queryExec(sprintf('
UPDATE releases r
SET r.nfostatus = %d
WHERE r.nzbstatus = %d
AND r.nfostatus < %d %s %s', self::NFO_FAILED, NZB::NZB_ADDED, $this->maxRetries, $groupIDQuery, $guidCharQuery));
if ($this->echo) {
if ($nfoCount > 0) {
echo PHP_EOL;
}
//.........这里部分代码省略.........
示例15: addSource
public function addSource($description, $username, $usermail, $usenetgroup, $publickey)
{
$db = new Settings();
$sql = sprintf("INSERT INTO spotnabsources " . "(description, username, useremail," . " usenetgroup, publickey, active) " . "VALUES (%s, %s, %s, %s, %s, 0)", $db->escapeString($description), $db->escapeString($username), $db->escapeString($usermail), $db->escapeString($usenetgroup), $db->escapeString($publickey));
return $db->queryInsert($sql);
}