本文整理汇总了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;
}