本文整理汇总了PHP中Releases::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Releases::getInstance方法的具体用法?PHP Releases::getInstance怎么用?PHP Releases::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Releases
的用法示例。
在下文中一共展示了Releases::getInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildPageTitlePart
public static function buildPageTitlePart($var)
{
$x = explode(':', $var[1]);
$name = false;
if (count($x) == 3) {
list($name, $paramtype, $paramvalue) = $x;
}
if (count($x) == 2) {
list($name, $paramvalue) = $x;
$paramtype = 'raw_get';
}
if ($name) {
$val = self::parseParams($paramtype, $paramvalue);
switch ($name) {
case 'profile-nickname':
$user = Users::getByIdsLoaded(array((int) $val));
$user = isset($user[$val]) ? $user[$val] : false;
/* @var $user User */
if ($user) {
return $user->getNickName();
}
break;
case 'release-title':
$release = Releases::getInstance()->getByIdLoaded((int) $val);
/* @var $release Release */
return $release->getTitle(1);
break;
case 'news-title':
$newsitem = News::getInstance()->getByIdLoaded((int) $val);
/* @var $newsitem NewsItem */
return $newsitem->getTitle(1);
break;
case 'book-title':
$book = Books::getInstance()->getByIdLoaded((int) $val);
/* @var $book Book */
return $book->getTitle(1);
break;
case 'person-title':
$person = Persons::getInstance()->getById((int) $val);
/* @var $person Person */
return $person->getName();
break;
case 'genre-title':
return Request::pass('genre-title');
break;
case 'forum-title':
$t = Request::pass('forum-title');
if (!$t) {
$t = Database::sql2single('SELECT name FROM `term_data` WHERE `tid`=' . (int) $val);
}
return $t;
break;
case 'post-subject':
return Request::pass('post-subject');
break;
case 'theme-title':
return Request::pass('theme-title');
break;
case 'serie-title':
$t = Request::pass('serie-title');
if (!$t) {
$t = Database::sql2single('SELECT `title` FROM `series` WHERE `id`=' . (int) $val);
}
return $t;
break;
case 'shelf-name':
if ($val == 'loved') {
return 'Любимые книги';
}
return isset(Config::$shelves[Config::$shelfIdByNames[$val]]) ? Config::$shelves[Config::$shelfIdByNames[$val]] : $val;
break;
case 'magazine-title':
$query = 'SELECT `title` FROM `magazines` WHERE `id`=' . (int) $val;
return Database::sql2single($query);
break;
case 'thread-subject':
$query = 'SELECT `subject` FROM `users_messages` WHERE `id`=' . (int) $val;
return Database::sql2single($query);
break;
case 'get':
return $val;
break;
default:
throw new Exception('Cant process title part "' . $var[1] . '"');
break;
}
}
}
示例2: foreach
Database::query('TRUNCATE `news`');
$query = 'SELECT * FROM `fashist`.`module_news` WHERE `type`=0';
$news = Database::sql2array($query, 'id');
foreach ($news as $id => $newsitem) {
$object = News::getInstance()->getById($id);
/* @var $object Newsitem */
$data = $newsitem;
$data['update_time'] = strtotime($data['update_time']);
$object->_create($data);
}
// releases
Database::query('TRUNCATE `releases`');
$query = 'SELECT * FROM `fashist`.`module_news` WHERE `type`=1';
$news = Database::sql2array($query, 'id');
foreach ($news as $id => $newsitem) {
$object = Releases::getInstance()->getById($id);
/* @var $object Release */
$data = $newsitem;
$data['update_time'] = strtotime($data['update_time']);
$object->_create($data);
}
//comments
Database::query('TRUNCATE `comments`');
Database::query('ALTER TABLE `comments` DROP PRIMARY KEY', false);
Database::query('INSERT INTO `comments` (SELECT * FROM `fashist`.`comments`)');
// all releases comments comes to releases comments!
$query = 'UPDATE `comments` SET `table`=\'releases\' WHERE `table`=\'news\' AND `doc_id` IN (SELECT `id` FROM `releases`)';
Database::query($query);
Database::query('ALTER TABLE `hardtechno`.`comments` ADD PRIMARY KEY ( `doc_id` , `table` , `id` ) ');
// upload
exec('rm -rf /home/test.hardtechno.ru/static/upload/news/*', $o);
示例3: _update
function _update($data)
{
$tableName = Releases::getInstance()->tableName;
$this->dropCache();
return parent::_update($data, $tableName);
}
示例4: setCollectionClass
function setCollectionClass()
{
$this->Collection = Releases::getInstance();
}