小编use*_*721的帖子

Cakephp - 从数据库和View中随机选择

我需要在我的帖子视图功能中创建三个随机链接到其他帖子.

控制器:

$random = $this->Post->find('all', array( 
             'order' => 'rand()',
             'limit' => 3,
             'conditions' => array('Post.status' => 'ok') 
             )); 
Run Code Online (Sandbox Code Playgroud)

但我不知道,如何为此写一个foreach.

谢谢

random select cakephp view

9
推荐指数
1
解决办法
1万
查看次数

Cakephp 2 - 检查用户是否登录视图

我需要一个显示元素,根据用户是否登录 - 在CakePHP 2.0中

这不起作用

<?php
  if ($this->Auth->loggedIn() 
    { 
    echo $this->element('user');
    }

  else 
    {
    echo $this->element('guest');
    } 
?>
Run Code Online (Sandbox Code Playgroud)

谢谢

authentication cakephp view

4
推荐指数
1
解决办法
9002
查看次数

标签 统计

cakephp ×2

view ×2

authentication ×1

random ×1

select ×1