本文整理汇总了PHP中Messages::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Messages::find方法的具体用法?PHP Messages::find怎么用?PHP Messages::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Messages
的用法示例。
在下文中一共展示了Messages::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct('Fireside');
// latest messages
$messages = new Messages();
$latestMessages = $messages->find()->orderBy('id DESC')->limit(20)->where(array('id' => '>0'));
foreach ($latestMessages as $message) {
$item = array('http://' . $_SERVER['HTTP_HOST'] . WWW_DIR . "/messages/show/{$message['topics_id']}/{$message['id']}" => array('title' => $message['name'], 'content' => 'Message by ' . $message['user'] . ' on ' . $message['created_at']));
$this->atomise($item);
}
$this->generate();
}
示例2: debugAction
public function debugAction()
{
$this->initalize();
$messages = Messages::find();
echo (new \Phalcon\Debug\Dump())->variable($messages, 'messages');
}
示例3: voteEntity
public function voteEntity($type, $entity_type)
{
//status is 1 for upvote, 0 for none, -1 for downvote
$entity_id = Input::get('id');
$member = Auth::user()->id;
$status = 0;
$user_exists = 0;
if ($entity_type) {
//Voting on a chat
$entity = Chats::find($entity_id);
$voted = new ChatsVoted();
$temp = $voted->whereuser_id($member)->wherechat_id($entity_id)->first();
$community = Communities::wherename(Auth::user()->page)->first();
if ($temp) {
$voted = $temp;
$status = $voted->status;
} else {
$voted->user_id = $member;
$voted->chat_id = $entity_id;
}
if (preg_match('/[a-zA-Z]/', $entity->admin)) {
$user = new User();
$user->name = $entity->admin;
$user = $user->findAll();
$user_exists = 1;
}
} else {
//voting on a message
$entity = Messages::find($entity_id);
$voted = new MessagesVoted();
$temp = $voted->whereuser_id($member)->wheremessage_id($entity_id)->first();
if ($temp) {
$voted = $temp;
$status = $voted->status;
} else {
$voted->user_id = $member;
$voted->message_id = $entity_id;
}
if (preg_match('/[a-zA-Z]/', $entity->author)) {
$user = new User();
$user->name = $entity->author;
$user = $user->findAll();
$user_exists = 1;
}
}
/* MODIFY USER COGNIZANCE BASED ON UP OR DOWN VOTE */
if ($user_exists) {
if ($user->name != Auth::user()->name) {
// create/modify asymmetric interaction
$interaction_user = InteractionUsers::whereuser_id(Auth::user()->id)->whereentity_id($user->id)->wheretype(0)->first();
if ($interaction_user) {
$interaction_user->bond = $interaction_user->bond - $status + $type;
if ($interaction_user->bond < 1) {
$interaction_user->delete();
} else {
$interaction_user->save();
}
$interaction_friend = InteractionUsers::whereentity_id(Auth::user()->id)->whereuser_id($user->id)->wheretype(0)->first();
if ($interaction_friend->bond < 1) {
$interaction_friend->delete();
} else {
$interaction_friend->save();
}
$interaction_friend->save();
} else {
if ($type - $status > 0) {
$inter_user = new InteractionUsers();
$inter_user->user_id = Auth::user()->id;
$inter_user->entity_id = $user->id;
$inter_user->bond = $type - $status;
$inter_user->save();
$inter_friend = new InteractionUsers();
$inter_friend->user_id = $user->id;
$inter_friend->entity_id = Auth::user()->id;
$inter_friend->bond = 1;
$inter_friend->save();
}
}
}
if ($user->level == 0) {
if ($type == -1 && ($status == 0 || $status == -1)) {
} else {
if ($type == 1 && $status == -1) {
$user->total_cognizance = $user->total_cognizance + 1;
if ($user->cognizance + 1 >= $user->next_level) {
$user->cognizance = ($user->cognizance + 1) % $user->next_level;
$user->level = $user->level + 1;
$user->next_level = $this->nextLevel($user->level);
} else {
$user->cognizance = ($user->cognizance + 1) % $user->next_level;
}
} else {
if ($type == -1 && $status == 1 || $type == 1 && $status == 1) {
$user->total_cognizance = $user->total_cognizance - 1;
if ($user->level > 0 && $user->cognizance - 1 < 0) {
$user->level = $user->level - 1;
$user->next_level = $this->nextLevel($user->level);
$user->cognizance = $user->next_level - 1;
} else {
$user->cognizance = ($user->cognizance - 1) % $user->next_level;
//.........这里部分代码省略.........