开发者

The save() method in cakePHP

I am doing some self-learning about cakePHP 1.26.

I got a table which has two fields {topic, username}

I got a simple HMTL form like this:

<input type=text name="data[testing][topic]" id="data[testing][topic]"/>

The data from this input field was passed to the specific controller with this code:

$who=$this->Session->read('user.name'); // username retrieved successfully
$this->Testing->save($this->data);

When I checked the database, 开发者_开发百科I could only see the data from the Input text field, but the username field is empty. How do I alter the code in the controller so that the username retrieved from the session can be saved into the database?

Could you help me please?


Like this:

$who=$this->Session->read('User.id');
$this->data['Testing']['user_id'] = $who; // set the data
$this->Testing->save($this->data);


$hello=$this->Session->read('Test.name');

$this->data['Testing']['test_name'] = $hello;

$this->Testing->save($this->data);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜