繁体   English   中英

在cakephp中将当前模型设置为数据库对象

[英]set current model to database object in cakephp

如何有效地将模型设置为数据库对象? 有什么比下面更好的方法呢?

    $user = $this->User->findByPassword($password, array('fields'=>'id'));
    $this->User = new User($user["User"]["id"]);
    $this->User->read();
    print_r($this->User);

我到处都看过,但是找不到。

你的意思是:

$user = $this->User->findByPassword($password, array('fields'=>'id'));
$this->User->id = $user["User"]["id"]; //set the id
print_r($this->User);

我是偶然得到的 这是我一直在寻找的一线客。

$this->User->set($this->User->findByPassword('first',$password));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM