当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::db方法代码示例

本文整理汇总了PHP中Pagekit\Application::db方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::db方法的具体用法?PHP Application::db怎么用?PHP Application::db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pagekit\Application的用法示例。


在下文中一共展示了Application::db方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getNrActiveSubmissions

 public function getNrActiveSubmissions()
 {
     if (!$this->id) {
         return 0;
     }
     return App::db()->createQueryBuilder()->from('@formmaker_submission')->where(['form_id' => $this->id, 'status' => Submission::STATUS_ACTIVE])->count();
 }
开发者ID:4nxiety,项目名称:pagekit-formmaker,代码行数:7,代码来源:Form.php

示例2: get

 /**
  * Method to get the system information
  *
  * @return string[]
  */
 public function get()
 {
     $server = new ServerBag($GLOBALS['_SERVER']);
     $info = [];
     $info['php'] = php_uname();
     if ($pdo = App::db()->getWrappedConnection() and $pdo instanceof PDOConnection) {
         $info['dbdriver'] = $pdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
         $info['dbversion'] = $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION);
         $info['dbclient'] = $pdo->getAttribute(\PDO::ATTR_CLIENT_VERSION);
     }
     $info['phpversion'] = phpversion();
     $info['server'] = $server->get('SERVER_SOFTWARE', getenv('SERVER_SOFTWARE'));
     $info['sapi_name'] = php_sapi_name();
     $info['version'] = App::version();
     $info['useragent'] = $server->get('HTTP_USER_AGENT');
     $info['extensions'] = implode(", ", get_loaded_extensions());
     $info['directories'] = $this->getDirectories();
     return $info;
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:24,代码来源:InfoHelper.php

示例3: editAction

 /**
  * @Route("/post/edit", name="post/edit")
  * @Access("blog: manage own posts || blog: manage all posts")
  * @Request({"id": "int"})
  */
 public function editAction($id = 0)
 {
     try {
         if (!($post = Post::where(compact('id'))->related('user')->first())) {
             if ($id) {
                 App::abort(404, __('Invalid post id.'));
             }
             $module = App::module('blog');
             $post = Post::create(['user_id' => App::user()->id, 'status' => Post::STATUS_DRAFT, 'date' => new \DateTime(), 'comment_status' => (bool) $module->config('posts.comments_enabled')]);
             $post->set('title', $module->config('posts.show_title'));
             $post->set('markdown', $module->config('posts.markdown_enabled'));
         }
         $user = App::user();
         if (!$user->hasAccess('blog: manage all posts') && $post->user_id !== $user->id) {
             App::abort(403, __('Insufficient User Rights.'));
         }
         $roles = App::db()->createQueryBuilder()->from('@system_role')->where(['id' => Role::ROLE_ADMINISTRATOR])->whereInSet('permissions', ['blog: manage all posts', 'blog: manage own posts'], false, 'OR')->execute('id')->fetchAll(\PDO::FETCH_COLUMN);
         $authors = App::db()->createQueryBuilder()->from('@system_user')->whereInSet('roles', $roles)->execute('id, username')->fetchAll();
         return ['$view' => ['title' => $id ? __('Edit Post') : __('Add Post'), 'name' => 'blog/admin/post-edit.php'], '$data' => ['post' => $post, 'statuses' => Post::getStatuses(), 'roles' => array_values(Role::findAll()), 'canEditAll' => $user->hasAccess('blog: manage all posts'), 'authors' => $authors], 'post' => $post];
     } catch (\Exception $e) {
         App::message()->error($e->getMessage());
         return App::redirect('@blog/post');
     }
 }
开发者ID:pagekit,项目名称:extension-blog,代码行数:29,代码来源:BlogController.php

示例4: addAlbum

 public function addAlbum(Media $media, $title, $artists = array())
 {
     $title = ucfirst(strtolower($title));
     $album = Album::query()->where('title = :title', ['title' => $title]);
     if ($album->count() > 0) {
         $album = $album->first();
     } else {
         if ($this->lastfm->isEnabled() && !is_null($artists) && count($artists) > 0) {
             $data = $this->lastfm->getAlbumInfo($title, $artists[0]->name);
             $summary = $data['wiki']['summary'];
             $image = $this->downloadImage($data['image']);
             if ($image === false) {
                 $image = '';
             }
         } else {
             $summary = '';
             $image = '';
         }
         $album = Album::create();
         $album->save(['title' => $title, 'summary' => $summary, 'image' => $image]);
     }
     //Dirty hack to create an insert query
     App::db()->createQueryBuilder()->select('1; INSERT INTO @shoutzor_media_album (media_id, album_id) VALUES (' . $media->id . ', ' . $album->id . ') ON DUPLICATE KEY UPDATE media_id=media_id;--')->execute();
     foreach ($artists as $artist) {
         App::db()->createQueryBuilder()->select('1; INSERT INTO @shoutzor_artist_album (artist_id, album_id) VALUES (' . $artist->id . ', ' . $album->id . ') ON DUPLICATE KEY UPDATE artist_id=artist_id;--')->execute();
     }
 }
开发者ID:xorinzor,项目名称:Shoutzor,代码行数:27,代码来源:Parser.php

示例5: installAction

 /**
  * @Request({"config": "array", "option": "array", "user": "array"})
  */
 public function installAction($config = [], $option = [], $user = [])
 {
     $status = $this->checkAction($config);
     $message = $status['message'];
     $status = $status['status'];
     try {
         if ('no-connection' == $status) {
             App::abort(400, __('No database connection.'));
         }
         if ('tables-exist' == $status) {
             App::abort(400, $message);
         }
         $scripts = new PackageScripts(App::path() . '/app/system/scripts.php');
         $scripts->install();
         App::db()->insert('@system_user', ['name' => $user['username'], 'username' => $user['username'], 'password' => App::get('auth.password')->hash($user['password']), 'status' => 1, 'email' => $user['email'], 'registered' => date('Y-m-d H:i:s'), 'roles' => '2,3']);
         $option['system']['version'] = App::version();
         $option['system']['extensions'] = ['blog'];
         $option['system']['site']['theme'] = 'theme-one';
         foreach ($option as $name => $values) {
             App::config()->set($name, App::config($name)->merge($values));
         }
         if ($this->packages) {
             $installer = new PackageManager(new NullOutput());
             $installer->install($this->packages);
         }
         if (file_exists(__DIR__ . '/../../install.php')) {
             require_once __DIR__ . '/../../install.php';
         }
         if (!$this->config) {
             $configuration = new Config();
             $configuration->set('application.debug', false);
             foreach ($config as $key => $value) {
                 $configuration->set($key, $value);
             }
             $configuration->set('system.secret', App::get('auth.random')->generateString(64));
             if (!file_put_contents($this->configFile, $configuration->dump())) {
                 $status = 'write-failed';
                 App::abort(400, __('Can\'t write config.'));
             }
         }
         App::module('system/cache')->clearCache();
         $status = 'success';
     } catch (DBALException $e) {
         $status = 'db-sql-failed';
         $message = __('Database error: %error%', ['%error%' => $e->getMessage()]);
     } catch (\Exception $e) {
         $message = $e->getMessage();
     }
     return ['status' => $status, 'message' => $message];
 }
开发者ID:sdaoudi,项目名称:rimbo,代码行数:53,代码来源:InstallerController.php

示例6: date

<?php

use Pagekit\Application as App;
App::config()->set('system/site', App::config('system/site')->merge(['frontpage' => 1, 'view' => ['logo' => 'storage/pagekit-logo.svg']]));
App::db()->insert('@system_config', ['name' => 'theme-one', 'value' => '{"logo_contrast":"storage\\/pagekit-logo-contrast.svg","_menus":{"main":"main","offcanvas":"main"},"_positions":{"hero":[1],"footer":[2]},"_widgets":{"1":{"title_hide":true,"title_size":"uk-panel-title","alignment":true,"html_class":"","panel":""},"2":{"title_hide":true,"title_size":"uk-panel-title","alignment":"","html_class":"","panel":""}},"_nodes":{"1":{"title_hide":true,"title_large":false,"alignment":true,"html_class":"","sidebar_first":false,"hero_image":"storage\\/home-hero.jpg","hero_viewport":true,"hero_contrast":true,"navbar_transparent":true}}}']);
App::db()->insert('@system_node', ['priority' => 1, 'status' => 1, 'title' => 'Home', 'slug' => 'home', 'path' => '/home', 'link' => '@page/1', 'type' => 'page', 'menu' => 'main', 'data' => "{\"defaults\":{\"id\":1}}"]);
App::db()->insert('@system_node', ['priority' => 2, 'status' => 1, 'title' => 'Blog', 'slug' => 'blog', 'path' => '/blog', 'link' => '@blog', 'type' => 'blog', 'menu' => 'main']);
App::db()->insert('@system_widget', ['title' => 'Hello, I\'m Pagekit', 'type' => 'system/text', 'status' => 1, 'nodes' => 1, 'data' => '{"content":"<h1 class=\\"uk-heading-large uk-margin-large-bottom\\">Hello, I\'m Pagekit,<br class=\\"uk-hidden-small\\"> your new favorite CMS.<\\/h1>\\n\\n<a class=\\"uk-button uk-button-large\\" href=\\"http:\\/\\/www.pagekit.com\\">Get started<\\/a>"}']);
App::db()->insert('@system_widget', ['title' => 'Socials', 'type' => 'system/text', 'status' => 1, 'data' => '{"content":"<ul class=\\"uk-grid uk-grid-medium uk-flex uk-flex-center\\">\\n    <li><a href=\\"https:\\/\\/github.com\\/pagekit\\" class=\\"uk-icon-hover uk-icon-small uk-icon-github\\"><\\/a><\\/li>\\n    <li><a href=\\"https:\\/\\/twitter.com\\/pagekit\\" class=\\"uk-icon-hover uk-icon-small uk-icon-twitter\\"><\\/a><\\/li>\\n    <li><a href=\\"https:\\/\\/gitter.im\\/pagekit\\/pagekit\\" class=\\"uk-icon-hover uk-icon-small uk-icon-comment-o\\"><\\/a><\\/li>\\n    <li><a href=\\"https:\\/\\/plus.google.com\\/communities\\/104125443335488004107\\" class=\\"uk-icon-hover uk-icon-small uk-icon-google-plus\\"><\\/a><\\/li>\\n<\\/ul>"}']);
App::db()->insert('@system_page', ['title' => 'Home', 'content' => "<div class=\"uk-width-medium-3-4 uk-container-center\">\n    \n<h3 class=\"uk-h1 uk-margin-large-bottom\">Uniting fresh design and clean code<br class=\"uk-hidden-small\"> to create beautiful websites.</h3>\n\n<p class=\"uk-width-medium-4-6 uk-container-center\">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>\n\n</div>", 'data' => '{"title":true}']);
App::db()->insert('@blog_post', ['user_id' => 1, 'slug' => 'hello-pagekit', 'title' => 'Hello Pagekit', 'status' => 2, 'date' => date('Y-m-d H:i:s'), 'modified' => date('Y-m-d H:i:s'), 'content' => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\nquis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\nconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\ncillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\nproident, sunt in culpa qui officia deserunt mollit anim id est laborum.", 'excerpt' => '', 'comment_status' => 1, 'data' => '{"title":null,"markdown":true}']);
开发者ID:4nxiety,项目名称:pagekit,代码行数:11,代码来源:install.php

示例7:

<?php

use Pagekit\Application as App;
App::config()->set('system/site', App::config('system/site')->merge(['frontpage' => 1, 'view' => ['logo' => 'storage/pagekit-logo.svg']]));
App::db()->insert('@system_node', ['priority' => 1, 'status' => 1, 'title' => 'Home', 'slug' => 'home', 'path' => '/home', 'link' => '@page/1', 'type' => 'page', 'menu' => 'main', 'data' => "{\"defaults\":{\"id\":1}}"]);
App::db()->insert('@system_node', ['priority' => 2, 'status' => 1, 'title' => 'Blog', 'slug' => 'blog', 'path' => '/blog', 'link' => '@blog', 'type' => 'blog', 'menu' => 'main']);
App::db()->insert('@system_widget', ['title' => 'Hello, I\'m Rimbo', 'type' => 'system/text', 'status' => 1, 'nodes' => 1, 'data' => '{"content":"<h1 class=\\"uk-heading-large uk-margin-large-bottom\\">Hello, I\'m Rimbo,<br class=\\"uk-hidden-small\\"> your new favorite CMS.<\\/h1>\\n\\n<a class=\\"uk-button uk-button-large\\" href=\\"http:\\/\\/www.pagekit.com\\">Get started<\\/a>"}']);
App::db()->insert('@system_widget', ['title' => 'Powered by Pagekit', 'type' => 'system/text', 'status' => 1, 'data' => '{"content":"<ul class=\\"uk-grid uk-grid-medium uk-flex uk-flex-center\\">\\n    <li><a href=\\"https:\\/\\/github.com\\/pagekit\\" class=\\"uk-icon-hover uk-icon-small uk-icon-github\\"><\\/a><\\/li>\\n    <li><a href=\\"https:\\/\\/twitter.com\\/pagekit\\" class=\\"uk-icon-hover uk-icon-small uk-icon-twitter\\"><\\/a><\\/li>\\n    <li><a href=\\"https:\\/\\/gitter.im\\/pagekit\\/pagekit\\" class=\\"uk-icon-hover uk-icon-small uk-icon-comment-o\\"><\\/a><\\/li>\\n    <li><a href=\\"https:\\/\\/plus.google.com\\/communities\\/104125443335488004107\\" class=\\"uk-icon-hover uk-icon-small uk-icon-google-plus\\"><\\/a><\\/li>\\n<\\/ul>\\n\\n<p>Powered by <a href=\\"https:\\/\\/pagekit.com\\">Pagekit<\\/a><\\/p>"}']);
开发者ID:aqnouch,项目名称:rimbo,代码行数:8,代码来源:install.php


注:本文中的Pagekit\Application::db方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。