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


PHP Post::get方法代码示例

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


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

示例1: array

// Following
$deletePosts = $addPosts = $deleteUsers = $addUsers = array();
use app\models\User;
use app\models\Post;
use Exception;
// for clarity's sake
foreach ($data as $userData) {
    try {
        echo "Looking for User # " . $userData->uid . "\n";
        $user = User::get($userData->uid);
        echo "User '" . $user . "' found\n";
        // following posts
        foreach ($userData->posts as $postData) {
            list($_pid, $_status) = $postData;
            try {
                $post = Post::get($_pid);
                if ($_status) {
                    $user->stopFollowingPost($post);
                    echo "- User '" . $user . "' stopped following Post '" . $post . "'\n";
                } else {
                    $user->startFollowingPost($post);
                    echo "+ User '" . $user . "' started following Post '" . $post . "'\n";
                }
            } catch (Exception $ex2) {
                // Care!
            }
        }
        // following users
        foreach ($userData->users as $followUserData) {
            list($_uid, $_status) = $followUserData;
            $followUser = User::get($_uid);
开发者ID:rudiedirkx,项目名称:Rudie-on-wheels,代码行数:31,代码来源:sync_favs.php

示例2: add_post

 public function add_post()
 {
     $validator = models\Post::validator('add');
     if (!empty($_POST)) {
         if ($validator->validate($_POST)) {
             $insert = $validator->output;
             $insert['author_id'] = $this->user->UserID();
             $insert['created_on'] = time();
             if ($pid = models\Post::insert($insert)) {
                 $post = models\Post::get($pid);
                 Session::success('Post Created. Look:');
                 // Send e-mail to $this->user's followers
                 /*					foreach ( $this->user->user->followers AS $user ) {
                 						Email::make($user->email, 'New post by '.$user, $user.' posted a new message on the blog. Read it at '.$post->url(array('absolute' => true)))->send();
                 					}*/
                 $this->_redirect($post->url());
             }
             Session::error('Couldn\'t save... =( Try again!?');
         }
     }
     $categories = $validator->options->categories;
     $messages = Session::messages();
     return $this->tpl->display('blog/post_form', get_defined_vars());
 }
开发者ID:rudiedirkx,项目名称:Rudie-on-wheels,代码行数:24,代码来源:blogController.php

示例3: post

 public function post($slug)
 {
     $post = Post::get($slug);
     return view('posts.show')->withPost($post);
 }
开发者ID:kiddlee,项目名称:blog-framework,代码行数:5,代码来源:PostController.php


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