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


PHP Post::update方法代码示例

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


在下文中一共展示了Post::update方法的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: hookCommentsRecount

 /**
  * Recalculate post comments count
  *
  * @param type $Comment
  */
 public function hookCommentsRecount($Comment)
 {
     $post = new Post();
     $post->id = $Comment->post_id;
     if ($post->find()) {
         $post->update(array('comments' => $this->db->where(array('post_id' => $post->id, 'published' => 1))->countAll('comments', 'id', TRUE)));
     }
 }
开发者ID:brussens,项目名称:cogear2,代码行数:13,代码来源:Gear.php

示例3: put_update

 public function put_update()
 {
     $id = Input::get('id');
     $validation = Post::validate(Input::all(), $id);
     if ($validation->fails()) {
         return Redirect::to_route('post_edit', $id)->with_errors($validation);
     } else {
         Post::update($id, array('title' => Input::get('title'), 'body' => Input::get('body'), 'author' => Input::get('author'), 'category_id' => Input::get('category')));
         return Redirect::to_route('post_show', $id)->with('message', 'Post has been updated!');
     }
 }
开发者ID:reeceballano,项目名称:Mayaten-Blog-Validation-Unique,代码行数:11,代码来源:posts.php

示例4: update

 public function update($id, $created)
 {
     if (!self::owner($id)) {
         throw new NotAuthorized();
     }
     if (!(int) $id) {
         throw new InvalidInput();
     }
     $timestamp = date('Y-m-d H:i:s', strtotime($created));
     $affected = Post::update($id, $timestamp);
     echo $affected . ' post(s) updated successfully.';
 }
开发者ID:natureday1,项目名称:Life,代码行数:12,代码来源:post.php

示例5: put_update

 public function put_update()
 {
     $validation = Post::validate(Input::all());
     $s = Input::get('title');
     $t = Str::slug($s);
     $post = Post::find(Input::get('id'));
     if ($validation->fails()) {
         return Redirect::to_route('post_edit', $post->slug)->with_errors($validation)->with_input();
     } else {
         Post::update(Input::get('id'), array('title' => Input::get('title'), 'body' => Input::get('body'), 'author' => Input::get('author'), 'category_id' => Input::get('category')));
         return Redirect::to_route('post_view', $post->slug)->with('message', 'Post has been updated successfully!');
     }
 }
开发者ID:reeceballano,项目名称:Mayaten-Blog,代码行数:13,代码来源:posts.php

示例6: update

 /**
  * Update the specified resource in storage.
  * @param $id
  * @internal param $post
  * @return Response
  */
 public function update($id)
 {
     $record = $this->blogRepository->findById($id);
     $val = $this->blogRepository->getEditForm($id);
     if (!$val->isValid()) {
         return Redirect::back()->with('errors', $val->getErrors())->withInput();
     }
     if (!$this->blogRepository->update($id, $val->getInputData())) {
         return Redirect::back()->with('errors', $this->blogRepository->errors())->withInput();
     }
     $tags = is_array(Input::get('tags')) ? array_filter(Input::get('tags')) : [];
     $this->tagRepository->attachTags($record, $tags);
     return Redirect::action('AdminBlogsController@edit', $id)->with('success', 'Updated');
 }
开发者ID:christiannwamba,项目名称:laravel-site,代码行数:20,代码来源:AdminBlogsController.php

示例7: update

 public function update()
 {
     $data = $_POST['Post'];
     if (isset($data['post_id'])) {
         $post = new Post();
         $post->title = $data['title'];
         $post->content = strip_tags($data['content']);
         if (isset($_FILES['Post'])) {
             $post->uploadImage($_FILES['Post']);
         }
         $post->status = $data['status'];
         $post->update($data['post_id']);
         if (isset($data['tags'])) {
             $post->updateTags($data['post_id'], $data['tags']);
         }
         Application::redirect(array('post' => 'edit'), array('id' => $data['post_id']));
     }
 }
开发者ID:RomsonApp,项目名称:blog,代码行数:18,代码来源:PostController.php

示例8: getPostUpdatePage

 static function getPostUpdatePage()
 {
     if (isset(Router::get('ids')[0])) {
         $post = new Post(Router::get('ids')[0]);
         $id = $post->get('id');
         $title = $post->get('title');
         $content = $post->get('content');
         $author = $post->get('author');
         if (unserialize($_SESSION['user'])->get('id') != $author->get('id')) {
             http_response_code(403);
             die('<h1>403 Accès interdit !</h1><p>Vous ne pouvez pas modifier cet article, vous n\'en êtes pas l\'auteur.</p>');
         }
     } else {
         $id = null;
         $title = null;
         $content = null;
         $author = null;
     }
     if (!(isset($_SESSION['user']) && $_SESSION['user'] != null)) {
         http_response_code(403);
         die('<h1>403 Accès interdit !</h1><p>Vous devez être connecté pour créer un article.</p><p><a href="' . Conf::$BASE_URL . '/user/login">Se connecter</a></p>');
     }
     if ($_POST != null) {
         extract($_POST);
         $errors = Post::checkErrors($_POST);
         if (count($errors) == 0) {
             if (!isset(Router::get('ids')[0])) {
                 $success = Post::create($title, $content, $author);
             } else {
                 $success = Post::update(Router::get('ids')[0], $title, $content);
             }
             if ($success) {
                 header('Location: ' . Conf::$BASE_URL . '/post/' . $success);
             }
         }
     }
     $action = Router::get('uri');
     $wording = Router::get('uri') == '/post/create' ? 'Créer' : 'Modifier';
     echo self::render('postUpdatePage', array('action' => $action, 'wording' => $wording, 'id' => $id, 'title' => $title, 'content' => $content, 'author' => $author));
 }
开发者ID:jekt,项目名称:blog-php,代码行数:40,代码来源:PostController.php

示例9: action_auth_ajax_wp_import_posts

    /**
     * The plugin sink for the auth_ajax_wp_import_posts hook.
     * Responds via authenticated ajax to requests for post importing.
     *
     * @param AjaxHandler $handler The handler that handled the request, contains $_POST info
     */
    public function action_auth_ajax_wp_import_posts($handler)
    {
        $valid_fields = array('db_name', 'db_host', 'db_user', 'db_pass', 'db_prefix', 'postindex', 'category_import', 'utw_import');
        $inputs = array_intersect_key($_POST->getArrayCopy(), array_flip($valid_fields));
        extract($inputs);
        if (!isset($inputs['category_import'])) {
            $inputs['category_import'] = 0;
        }
        if (!isset($inputs['utw_import'])) {
            $inputs['utw_import'] = 0;
        }
        $wpdb = $this->wp_connect($db_host, $db_name, $db_user, $db_pass, $db_prefix);
        if ($wpdb) {
            if (!DB::in_transaction()) {
                DB::begin_transaction();
            }
            $has_taxonomy = count($wpdb->get_column("SHOW TABLES LIKE '{$db_prefix}term_taxonomy';"));
            $postcount = $wpdb->get_value("SELECT count( id ) FROM {$db_prefix}posts;");
            $min = $postindex * IMPORT_BATCH + ($postindex == 0 ? 0 : 1);
            $max = min(($postindex + 1) * IMPORT_BATCH, $postcount);
            $user_map = array();
            $userinfo = DB::table('userinfo');
            $user_info = DB::get_results("SELECT user_id, value FROM {$userinfo} WHERE name= 'wp_id';");
            foreach ($user_info as $info) {
                $user_map[$info->value] = $info->user_id;
            }
            echo "<p>Importing posts {$min}-{$max} of {$postcount}.</p>";
            $posts = $wpdb->get_results("\n\t\t\t\tSELECT\n\t\t\t\t\tpost_content as content,\n\t\t\t\t\tID as id,\n\t\t\t\t\tpost_title as title,\n\t\t\t\t\tpost_name as slug,\n\t\t\t\t\tpost_author as user_id,\n\t\t\t\t\tguid as guid,\n\t\t\t\t\tpost_date as pubdate,\n\t\t\t\t\tpost_modified as updated,\n\t\t\t\t\tpost_status,\n\t\t\t\t\tpost_type\n\t\t\t\tFROM {$db_prefix}posts\n\t\t\t\tWHERE post_type != 'revision' AND post_type != 'attachment'\n\t\t\t\tORDER BY ID DESC\n\t\t\t\tLIMIT {$min}, " . IMPORT_BATCH, array(), 'Post');
            $post_map = DB::get_column("SELECT value FROM {postinfo} WHERE name='wp_id';");
            foreach ($posts as $post) {
                if (in_array($post->id, $post_map)) {
                    continue;
                }
                if ($has_taxonomy) {
                    // Importing from >= WP2.3
                    if ($category_import == 1) {
                        // Import WP category and tags as tags
                        $taxonomies = "({$db_prefix}term_taxonomy.taxonomy= 'category' OR {$db_prefix}term_taxonomy.taxonomy= 'post_tag')";
                    } else {
                        // Import WP tags as tags
                        $taxonomies = "{$db_prefix}term_taxonomy.taxonomy= 'post_tag'";
                    }
                    $tags = $wpdb->get_column("SELECT DISTINCT name\n\t\t\t\t\t\tFROM {$db_prefix}terms\n\t\t\t\t\t\tINNER JOIN {$db_prefix}term_taxonomy\n\t\t\t\t\t\tON ( {$db_prefix}terms.term_id= {$db_prefix}term_taxonomy.term_id AND {$taxonomies} )\n\t\t\t\t\t\tINNER JOIN {$db_prefix}term_relationships\n\t\t\t\t\t\tON ({$db_prefix}term_taxonomy.term_taxonomy_id= {$db_prefix}term_relationships.term_taxonomy_id)\n\t\t\t\t\t\tWHERE {$db_prefix}term_relationships.object_id= {$post->id}");
                } else {
                    // Importing from < WP2.3
                    if ($category_import == 1) {
                        // Import WP category as tags
                        $tags = $wpdb->get_column("SELECT category_nicename\n\t\t\t\t\t\t\tFROM {$db_prefix}post2cat\n\t\t\t\t\t\t\tINNER JOIN {$db_prefix}categories\n\t\t\t\t\t\t\tON ( {$db_prefix}categories.cat_ID= {$db_prefix}post2cat.category_id )\n\t\t\t\t\t\t\tWHERE post_id= {$post->id}");
                    } else {
                        $tags = array();
                    }
                }
                // we want to include the Ultimate Tag Warrior in that list of tags
                if ($utw_import == 1 && count(DB::get_results("show tables like 'post2tag'"))) {
                    $utw_tags = $wpdb->get_column("SELECT tag\n\t\t\t\t\tFROM {$db_prefix}post2tag\n\t\t\t\t\tINNER JOIN {$db_prefix}tags\n\t\t\t\t\tON ( {$db_prefix}tags.tag_ID= {$db_prefix}post2tag.tag_id )\n\t\t\t\t\tWHERE post_id= {$post->id}");
                    // UTW substitutes underscores and hyphens for spaces, so let's do the same
                    $utw_tag_formatter = create_function('$a', 'return preg_replace( "/_|-/", " ", $a );');
                    // can this be done in just two calls instead of three? I think so.
                    $tags = array_unique(array_merge($tags, array_map($utw_tag_formatter, $utw_tags)));
                }
                $post->content = MultiByte::convert_encoding($post->content);
                $post->title = MultiByte::convert_encoding($post->title);
                $tags = implode(',', $tags);
                $tags = MultiByte::convert_encoding($tags);
                $post_array = $post->to_array();
                switch ($post_array['post_status']) {
                    case 'publish':
                        $post_array['status'] = Post::status('published');
                        break;
                    default:
                        $post_array['status'] = Post::status($post_array['post_status']);
                        break;
                }
                unset($post_array['post_status']);
                switch ($post_array['post_type']) {
                    case 'post':
                        $post_array['content_type'] = Post::type('entry');
                        break;
                    case 'page':
                        $post_array['content_type'] = Post::type('page');
                        break;
                    default:
                        // We're not inserting WP's media records.  That would be silly.
                        continue;
                }
                unset($post_array['post_type']);
                $p = new Post($post_array);
                $p->slug = $post->slug;
                if (isset($user_map[$p->user_id])) {
                    $p->user_id = $user_map[$p->user_id];
                } else {
                    $errors = Options::get('import_errors');
                    $errors[] = _t('Post author id %s was not found in WP database, assigning post "%s" (WP post id #%d) to current user.', array($p->user_id, $p->title, $post_array['id']));
                    Options::set('import_errors', $errors);
//.........这里部分代码省略.........
开发者ID:anupom,项目名称:my-blog,代码行数:101,代码来源:wpimport.plugin.php

示例10:

        break;
    case 'edit':
        //各条件
        $cont->edit(20);
        break;
    case 'destroy':
        //各条件
        $cont->destroy(10);
        break;
    case 'view':
        //各条件
        $modl->view(10);
        break;
    case 'update':
        //各条件
        $modl->update(10);
        break;
    case 'delete':
        //各条件
        $modl->delete(10);
        break;
    default:
        echo 'It is error';
        break;
}
//controller class
class PostController
{
    //property
    private $resouce = '';
    private $action = '';
开发者ID:ta9yeah,项目名称:Fw_twitter_bbs,代码行数:31,代码来源:posts_controller.php

示例11: unset

         Notify::error($errors);
         return Response::redirect('admin/posts/edit/' . $id);
     }
     $current_post = Post::find($id);
     if ($current_post->status == 'draft') {
         $input['created'] = Date::mysql('now');
     } else {
         unset($input['created']);
     }
     if (is_null($input['comments'])) {
         $input['comments'] = 0;
     }
     if (empty($input['html'])) {
         $input['status'] = 'draft';
     }
     Post::update($id, $input);
     Extend::process('post', $id);
     Notify::success(__('posts.updated'));
     return Response::redirect('admin/posts/edit/' . $id);
 });
 /*
 	Add new post
 */
 Route::get('admin/posts/add', function () {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     $vars['page'] = Registry::get('posts_page');
     // extended fields
     $vars['fields'] = Extend::fields('post');
     $vars['statuses'] = array('published' => __('global.published'), 'draft' => __('global.draft'), 'archived' => __('global.archived'));
     $vars['categories'] = Category::dropdown();
开发者ID:pepfi,项目名称:anchor-cms,代码行数:31,代码来源:posts.php

示例12: importer


//.........这里部分代码省略.........
                    if (!empty($node['tag'][$i]['.value'])) {
                        array_push($post->tags, $node['tag'][$i]['.value']);
                    }
                }
            }
            if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) {
                $post->content = nl2brWithHTML($post->content);
            }
            if (!$post->add()) {
                user_error(__LINE__ . $post->error);
            }
            if (isset($node['attachment'])) {
                for ($i = 0; $i < count($node['attachment']); $i++) {
                    $attachment = new Attachment();
                    $attachment->parent = $post->id;
                    $cursor =& $node['attachment'][$i];
                    $attachment->name = $cursor['name'][0]['.value'];
                    $attachment->label = $cursor['label'][0]['.value'];
                    $attachment->mime = @$cursor['.attributes']['mime'];
                    $attachment->size = $cursor['.attributes']['size'];
                    $attachment->width = $cursor['.attributes']['width'];
                    $attachment->height = $cursor['.attributes']['height'];
                    $attachment->enclosure = @$cursor['enclosure'][0]['.value'];
                    $attachment->attached = $cursor['attached'][0]['.value'];
                    $attachment->downloads = @$cursor['downloads'][0]['.value'];
                    if (!$attachment->add()) {
                        user_error(__LINE__ . $attachment->error);
                    } else {
                        if ($cursor['name'][0]['.value'] != $attachment->name) {
                            $post2 = new Post();
                            if ($post2->open($post->id, 'id, content')) {
                                $post2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $post2->content);
                                $post2->loadTags();
                                $post2->update();
                                $post2->close();
                            }
                            unset($post2);
                        }
                    }
                    if (!empty($cursor['content'][0]['.stream'])) {
                        Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        fclose($cursor['content'][0]['.stream']);
                        unset($cursor['content'][0]['.stream']);
                    }
                }
            }
            if (isset($node['comment'])) {
                for ($i = 0; $i < count($node['comment']); $i++) {
                    $comment = new Comment();
                    $comment->entry = $post->id;
                    $cursor =& $node['comment'][$i];
                    $comment->name = $cursor['commenter'][0]['name'][0]['.value'];
                    if (!empty($cursor['id'][0]['.value'])) {
                        $comment->id = $cursor['id'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['.attributes']['id'])) {
                        $comment->commenter = $cursor['commenter'][0]['.attributes']['id'];
                    }
                    if (!empty($cursor['commenter'][0]['homepage'][0]['.value'])) {
                        $comment->homepage = $cursor['commenter'][0]['homepage'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['ip'][0]['.value'])) {
                        $comment->ip = $cursor['commenter'][0]['ip'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['openid'][0]['.value'])) {
开发者ID:webhacking,项目名称:Textcube,代码行数:67,代码来源:index.php

示例13: updateProcess

function updateProcess($id)
{
    $send = Request::get('send');
    $valid = Validator::make(array('send.title' => 'min:1|slashes', 'send.keywords' => 'slashes', 'tags' => 'slashes', 'send.catid' => 'slashes', 'send.type' => 'slashes', 'send.allowcomment' => 'slashes'));
    if (!$valid) {
        throw new Exception("Error Processing Request. Error: " . Validator::getMessage());
    }
    $uploadMethod = Request::get('uploadMethod');
    $loadData = Post::get(array('where' => "where postid='{$id}'"));
    if (!isset($loadData[0]['postid'])) {
        throw new Exception("This post not exists.");
    }
    switch ($uploadMethod) {
        case 'frompc':
            if (Request::hasFile('imageFromPC')) {
                if (Request::isImage('imageFromPC')) {
                    $send['image'] = File::upload('imageFromPC');
                    File::remove($loadData[0]['image']);
                }
            }
            break;
        case 'fromurl':
            if (Request::isImage('imageFromUrl')) {
                $url = Request::get('imageFromUrl');
                $send['image'] = File::upload('uploadFromUrl');
                File::remove($loadData[0]['image']);
            }
            break;
    }
    $send['userid'] = Users::getCookieUserId();
    if (!Request::has('send.catid')) {
        $loadCat = Categories::get(array('limitShow' => 1));
        if (isset($loadCat[0]['catid'])) {
            $send['catid'] = $loadCat[0]['catid'];
        }
    }
    if (!Post::update($id, $send)) {
        throw new Exception("Error. " . Database::$error);
    }
    PostTags::remove($id, " postid='{$id}' ");
    $tags = trim(Request::get('tags'));
    $parse = explode(',', $tags);
    $total = count($parse);
    $insertData = array();
    for ($i = 0; $i < $total; $i++) {
        $insertData[$i]['title'] = trim($parse[$i]);
        $insertData[$i]['postid'] = $id;
    }
    PostTags::insert($insertData);
}
开发者ID:neworldwebsites,项目名称:noblessecms,代码行数:50,代码来源:post.php

示例14: update_one

 public function update_one($params = [])
 {
     global $_PUT;
     Post::update($_PUT, $params['id']);
     Render::json(Post::read_formatted($params['id']));
 }
开发者ID:wileybenet,项目名称:mobile-docs,代码行数:6,代码来源:post_ctrl.php

示例15: approveComment

 /**
  * Approve a comment
  */
 function approveComment()
 {
     Doo::loadModel('Comment');
     $c = new Comment();
     $c->id = intval($this->params['cid']);
     $comment = $c->find(array('limit' => 1, 'select' => 'id, post_id'));
     //if not exists, show error
     if ($comment == Null) {
         return 404;
     }
     //change status to Approved
     $comment->status = 1;
     $comment->update(array('field' => 'status'));
     Doo::loadModel('Post');
     Doo::autoload('DooDbExpression');
     //Update totalcomment field in Post
     $p = new Post();
     $p->id = $comment->post_id;
     $p->totalcomment = new DooDbExpression('totalcomment+1');
     $p->update(array('field' => 'totalcomment'));
     $data['rootUrl'] = Doo::conf()->APP_URL;
     $data['title'] = 'Comment Approved!';
     $data['content'] = "<p>Comment is approved successfully!</p>";
     $data['content'] .= "<p>View the comment <a href=\"{$data['rootUrl']}article/{$p->id}#comment{$comment->id}\">here</a></p>";
     $this->render('admin_msg', $data);
 }
开发者ID:mindaugas-valinskis,项目名称:doophp,代码行数:29,代码来源:AdminController.php


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