本文整理汇总了PHP中storage::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP storage::instance方法的具体用法?PHP storage::instance怎么用?PHP storage::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类storage
的用法示例。
在下文中一共展示了storage::instance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
public function install($db_type)
{
$f3 = \Base::instance();
$db_type = strtoupper($db_type);
if ($db = storage::instance()->get($db_type)) {
$f3->set('DB', $db);
} else {
$f3->error(256, 'no valid DB specified');
}
// setup the models
\Model\Post::setup();
\Model\Tag::setup();
\Model\Comment::setup();
\Model\User::setup();
// create demo admin user
$user = new \Model\User();
$user->load(array('username = ?', 'admin'));
if ($user->dry()) {
$user->username = 'admin';
$user->name = 'Administrator';
$user->password = 'fabulog';
$user->save();
\Flash::instance()->addMessage('Admin User created,' . ' username: admin, password: fabulog', 'success');
}
\Flash::instance()->addMessage('Setup complete', 'success');
}
示例2: sprintf
}
if (!is_writable('app/data/')) {
$preErr[] = sprintf('please make sure that the \'%s\' directory is writable.', 'app/data/');
}
if (!is_writable('app/data/config.json')) {
$preErr[] = sprintf('please make sure that the \'%s\' file is writable.', 'app/data/config.json');
}
if (isset($preErr)) {
header('Content-Type: text;');
die(implode("\n", $preErr));
}
$f3->config('app/config.ini');
## DB Setup
$cfg = Config::instance();
if ($cfg->ACTIVE_DB) {
$f3->set('DB', storage::instance()->get($cfg->ACTIVE_DB));
} else {
$f3->error(500, 'Sorry, but there is no active DB setup.');
}
$f3->set('CONFIG', $cfg);
$f3->set('FLASH', Flash::instance());
\Template::instance()->extend('image', '\\Template\\Tags\\Image::render');
\Template::instance()->extend('pagebrowser', '\\Pagination::renderTag');
// Handles all <form> data
\Template\FooForms::init();
## POSTS
// view list
$f3->route(array('GET /', 'GET /page/@page'), 'Controller\\Post->getList');
// view single
$f3->route(array('GET /@slug', 'GET /post/@id'), 'Controller\\Post->getSingle');
// post comment
示例3: addChapter
public function addChapter($storyID, $post)
{
$location = \Config::instance()->chapter_data_location;
// Get current chapter count and raise
if (FALSE == ($chapterCount = @$this->exec("SELECT COUNT(chapid) as chapters FROM `tbl_chapters` WHERE `sid` = :sid ", [":sid" => $storyID])[0]['chapters'])) {
return FALSE;
}
$chapterCount++;
$kv = ['title' => $post['chapter_title'], 'inorder' => $chapterCount, 'notes' => $post['chapter_notes'], 'validated' => "1", 'wordcount' => $this->str_word_count_utf8($post['chapter_text']), 'rating' => "0", 'sid' => $storyID];
if ($location != "local") {
$kv['chaptertext'] = $post['chapter_text'];
}
$chapterID = $this->insertArray($this->prefix . 'chapters', $kv);
if ($location == "local") {
$db = \storage::instance()->localChapterDB();
$chapterAdd = @$db->exec('INSERT INTO "chapters" ("chapid","sid","inorder","chaptertext") VALUES ( :chapid, :sid, :inorder, :chaptertext )', [':chapid' => $chapterID, ':sid' => $storyID, ':inorder' => $chapterCount, ':chaptertext' => $post['chapter_text']]);
}
$this->rebuildStoryCache($storyID);
return $chapterID;
}
示例4: saveChapter
public function saveChapter($chapterID, $chapterText)
{
$location = \Config::instance()->chapter_data_location;
if ($location == "local") {
$db = \storage::instance()->localChapterDB();
$chapterSave = @$db->exec('UPDATE "chapters" SET "chaptertext" = :chaptertext WHERE "chapid" = :chapid', array(':chapid' => $chapterID, ':chaptertext' => $chapterText));
} else {
$chapterSave = $this->exec('UPDATE `tbl_chapters` SET `chaptertext` = :chaptertext WHERE `chapid` = :chapid', array(':chapid' => $chapterID, ':chaptertext' => $chapterText));
}
return $chapterSave;
}