本文整理匯總了PHP中Railpage\AppCore::getDatabase方法的典型用法代碼示例。如果您正苦於以下問題:PHP AppCore::getDatabase方法的具體用法?PHP AppCore::getDatabase怎麽用?PHP AppCore::getDatabase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Railpage\AppCore
的用法示例。
在下文中一共展示了AppCore::getDatabase方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: CreateArticle
/**
* Return a news article
* @since Version 3.9.1
* @return \Railpage\News\Article
* @param int|string $id
*/
public static function CreateArticle($id)
{
$Redis = AppCore::getRedis();
$Memcached = AppCore::getMemcached();
$Registry = Registry::getInstance();
/**
* Lookup article slug-to-ID first
*/
if (!filter_var($id, FILTER_VALIDATE_INT)) {
$mckey = sprintf("railpage:news.article_slug=%s", $id);
if (!($article_id = $Memcached->fetch($mckey))) {
$Database = AppCore::getDatabase();
$article_id = $Database->fetchOne("SELECT sid FROM nuke_stories WHERE slug = ?", $id);
}
if (!filter_var($article_id, FILTER_VALIDATE_INT)) {
throw new Exception("Could not find an article ID matching URL slug " . $id);
}
$id = $article_id;
}
/**
* We have an integer article ID, so go ahead and load it
*/
$regkey = sprintf(Article::REGISTRY_KEY, $id);
try {
$Article = $Registry->get($regkey);
} catch (Exception $e) {
if ($Article = $Redis->fetch($regkey)) {
$Article->Memcached = $Memcached;
$Article->Redis = $Redis;
$Database = AppCore::getDatabase();
$Article->setDatabaseConnection($Database)->setDatabaseReadOnlyConnection($Database);
} else {
$Article = new Article($id);
$Redis->save($regkey, $Article);
}
$Registry->set($regkey, $Article);
}
return $Article;
}
示例2: lastWeeklyDispatchDate
/**
* Get last newsletter dispatch date
* @since Version 3.10.0
* @param \Railpage\Users\User $User
* @return \DateTime
*/
public static function lastWeeklyDispatchDate(User $User)
{
$query = "SELECT newsletter_weekly_last FROM nuke_users_flags WHERE user_id = ?";
$date = AppCore::getDatabase()->fetchOne($query, $User->id);
if ($date) {
return new DateTime($date);
}
return false;
}