cakephp 3显示包含的最新值

时间:2015-08-02 19:56:05

标签: cakephp cakephp-3.0

我对cakephp有点问题 我有DB 测量器=> id,标题,颜色...... 用法=> id,measurer_id,value ...

我希望做类似

的事情
$this->paginate = [
    'contain' => [
        'MeasurerTypes',
        'Usages' => function($q) {
            return $q->find('latest');
        }
    ],
    'finder' => ['my' => $this->user['id']]
];
$this->set('title',__('My measurers'));
$this->set('measurers', $this->paginate($this->Measurers));
$this->set('_serialize', ['measurers']);

这只是示例代码,是否只找到一个最新变量而没有所有列表?

1 个答案:

答案 0 :(得分:0)

检查一下:

  

http://book.cakephp.org/2.0/en/models/additional-methods-and-properties.html#model-getinsertid

示例:

$result = $articles->find('all')->all();

// Get the first and/or last result.
$row = $result->first();
$row = $result->last();

编辑: 在CakePHP 3中

  

http://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html

@Path("/user")
public class UserWS
{
    @EJB
    SB_usrRemote sb_usrRemote;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String checkLoginAttempt(String username, String password)
    {
        return sb_usrRemote.checkLoginAttempt(username, password).toString();
    }
}