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


PHP Base::table方法代码示例

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


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

示例1: up

 public function up()
 {
     $table = Base::table('pages');
     $table2 = Base::table('posts');
     if ($this->has_table_column($table, 'content')) {
         $sql = 'ALTER TABLE `' . $table . '` ';
         $sql .= 'CHANGE `content` `markdown` TEXT';
         DB::ask($sql);
     }
     if (!$this->has_table_column($table, 'html') && $this->has_table_column($table, 'markdown')) {
         $sql = 'ALTER TABLE `' . $table . '` ';
         $sql .= 'ADD `html` TEXT NOT NULL AFTER `markdown`';
         DB::ask($sql);
         $pages = Page::sort('menu_order', 'desc')->get();
         foreach ($pages as $page) {
             Page::update($page->id, array('html' => parse($page->markdown)));
         }
     }
     if (!$this->has_table_column($table2, 'markdown') && $this->has_table_column($table2, 'html')) {
         $sql = 'ALTER TABLE `' . $table2 . '` ';
         $sql .= 'ADD `markdown` TEXT NOT NULL AFTER `description`';
         DB::ask($sql);
         $migrate_data_sql = 'update `' . $table2 . '` set `markdown` = `html`, `html` = "";';
         DB::ask($migrate_data_sql);
         $posts = Post::sort('created', 'desc')->get();
         foreach ($posts as $post) {
             Post::update($post->id, array('html' => parse($post->markdown)));
         }
     }
 }
开发者ID:anchorcms,项目名称:anchor-cms,代码行数:30,代码来源:211_alter_post_page_content.php

示例2: down

 public function down()
 {
     $posts = Base::table('posts');
     if ($this->has_table($posts)) {
         if ($this->has_table_column($posts, 'updated')) {
             $sql = 'ALTER TABLE `' . $posts . '` ';
             $sql .= 'DROP COLUMN `updated`';
             DB::ask($sql);
         }
     }
     $pages = Base::table('pages');
     if ($this->has_table($pages)) {
         if ($this->has_table_column($pages, 'updated')) {
             $sql = 'ALTER TABLE `' . $pages . '` ';
             $sql .= 'DROP COLUMN `updated`';
             DB::ask($sql);
         }
     }
     $users = Base::table('users');
     if ($this->has_table($users)) {
         if ($this->has_table_column($users, 'updated')) {
             $sql = 'ALTER TABLE `' . $users . '` ';
             $sql .= 'DROP COLUMN `updated`';
             DB::ask($sql);
         }
     }
 }
开发者ID:anchorcms,项目名称:anchor-cms,代码行数:27,代码来源:213_add_updated_fields_to_tables.php

示例3: search

 public static function search($term, $page = 1, $per_page = 10)
 {
     $query = static::left_join(Base::table('users'), Base::table('users.id'), '=', Base::table('posts.author'))->where(Base::table('posts.status'), '=', 'published')->where(Base::table('posts.title'), 'like', '%' . $term . '%');
     $total = $query->count();
     $posts = $query->take($per_page)->skip(--$page * $per_page)->get(array(Base::table('posts.*'), Base::table('users.id as author_id'), Base::table('users.bio as author_bio'), Base::table('users.real_name as author_name')));
     return array($total, $posts);
 }
开发者ID:svita-cz,项目名称:web,代码行数:7,代码来源:post.php

示例4: up

 public function up()
 {
     $table = Base::table('comments');
     if ($this->has_table($table)) {
         $sql = 'ALTER TABLE `' . $table . '` CHANGE `date` `date` datetime NOT NULL AFTER `status`';
         DB::ask($sql);
     }
 }
开发者ID:biggtfish,项目名称:anchor-cms,代码行数:8,代码来源:21_alter_comments_date.php

示例5: up

 public function up()
 {
     $table = Base::table('posts');
     if ($this->has_table_column($table, 'created')) {
         $sql = 'ALTER TABLE `' . $table . '` CHANGE `created` `created` datetime NOT NULL AFTER `js`';
         DB::ask($sql);
     }
 }
开发者ID:biggtfish,项目名称:anchor-cms,代码行数:8,代码来源:61_alter_posts_created.php

示例6: up

 public function up()
 {
     $table = Base::table('posts');
     if (!$this->has_table_column($table, 'category')) {
         $sql = 'ALTER TABLE `' . $table . '` ADD `category` int(6) NOT NULL AFTER `author`';
         DB::query($sql);
     }
 }
开发者ID:biggtfish,项目名称:anchor-cms,代码行数:8,代码来源:62_add_posts_category.php

示例7: down

 public function down()
 {
     $table = Base::table('extend');
     if ($this->has_table_column($table, 'type')) {
         $sql = 'ALTER TABLE `' . $table . '` MODIFY COLUMN `type` enum("post", "page") NOT NULL';
         DB::ask($sql);
     }
 }
开发者ID:anchorcms,项目名称:anchor-cms,代码行数:8,代码来源:170_add_category_cust_field.php

示例8: up

 public function up()
 {
     $table = Base::table('category_meta');
     if (!$this->has_table($table)) {
         $sql = "CREATE TABLE IF NOT EXISTS `" . $table . "` (\n                `id` int(6) NOT NULL AUTO_INCREMENT,\n                `category` int(6) NOT NULL,\n                `extend` int(6) NOT NULL,\n                `data` text NOT NULL,\n                PRIMARY KEY (`id`),\n                KEY `item` (`category`),\n                KEY `extend` (`extend`)\n            ) ENGINE=InnoDB";
         DB::ask($sql);
     }
 }
开发者ID:anchorcms,项目名称:anchor-cms,代码行数:8,代码来源:169_add_category_meta.php

示例9: up

 public function up()
 {
     $table = Base::table('extend');
     if (!$this->has_table($table)) {
         $sql = "CREATE TABLE IF NOT EXISTS `' . {$table} . '` (\n\t\t\t\t`id` int(6) NOT NULL AUTO_INCREMENT,\n\t\t\t\t`type` enum('post','page') NOT NULL,\n\t\t\t\t`field` enum('text','html','image','file') NOT NULL,\n\t\t\t\t`key` varchar(160) NOT NULL,\n\t\t\t\t`label` varchar(160) NOT NULL,\n\t\t\t\t`attributes` text NOT NULL,\n\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t) ENGINE=InnoDB";
         DB::ask($sql);
     }
 }
开发者ID:anchorcms,项目名称:anchor-cms,代码行数:8,代码来源:30_create_extend_table.php

示例10: up

 public function up()
 {
     $table = Base::table('pages');
     if (!$this->has_table_column($table, 'parent')) {
         $sql = 'ALTER TABLE `' . $table . '` ADD `parent` int(6) NOT NULL AFTER `id`';
         DB::ask($sql);
     }
 }
开发者ID:anchorcms,项目名称:anchor-cms,代码行数:8,代码来源:120_add_page_parent.php

示例11: up

 public function up()
 {
     $table = Base::table('comments');
     if ($this->has_table($table)) {
         $sql = 'ALTER TABLE `' . $table . '` CHANGE `status` `status` enum(\'pending\',\'approved\',\'spam\') NOT NULL AFTER `post`';
         DB::ask($sql);
     }
 }
开发者ID:biggtfish,项目名称:anchor-cms,代码行数:8,代码来源:20_alter_comments_status.php

示例12: up

 public function up()
 {
     $table = Base::table('page_meta');
     if (!$this->has_table($table)) {
         $sql = "CREATE TABLE IF NOT EXISTS `' . {$table} . '` (\n\t\t\t\t`id` int(6) NOT NULL AUTO_INCREMENT,\n\t\t\t\t`page` int(6) NOT NULL,\n\t\t\t\t`extend` int(6) NOT NULL,\n\t\t\t\t`data` text NOT NULL,\n\t\t\t\tPRIMARY KEY (`id`),\n\t\t\t\tKEY `page` (`page`),\n\t\t\t\tKEY `extend` (`extend`)\n\t\t\t) ENGINE=InnoDB";
         DB::ask($sql);
     }
 }
开发者ID:biggtfish,项目名称:anchor-cms,代码行数:8,代码来源:40_create_page_meta_table.php

示例13: up

 public function up()
 {
     $table = Base::table('meta');
     if ($this->has_table($table)) {
         if (!Query::table($table)->where('key', '=', 'comment_notifications')->count()) {
             Query::table($table)->insert(array('key' => 'comment_notifications', 'value' => 0));
         }
     }
 }
开发者ID:anchorcms,项目名称:anchor-cms,代码行数:9,代码来源:10_add_comment_notifications.php

示例14: up

 public function up()
 {
     $table = Base::table('categories');
     if ($this->has_table($table)) {
         if (!Query::table($table)->count()) {
             Query::table($table)->insert(array('title' => 'Uncategorised', 'slug' => 'uncategorised', 'description' => 'Ain\'t no category here.'));
         }
     }
 }
开发者ID:biggtfish,项目名称:anchor-cms,代码行数:9,代码来源:71_insert_default_categories.php

示例15: up

 public function up()
 {
     $table = Base::table('pages');
     if ($this->has_table_column($table, 'menu_order')) {
         $sql = 'ALTER TABLE `' . $table . '`;';
         $sql .= 'ALTER COLUMN `menu_order` SET DEFAULT 0';
         DB::ask($sql);
     }
 }
开发者ID:biggtfish,项目名称:anchor-cms,代码行数:9,代码来源:210_fix_page_menu_order.php


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