2013-11-11 14:17:46  浏览:1357

cakephp

cakephp中,不允许直接修改$this->request->data

但是可以用下面的方式设置

//取值

$this->request->data('Post.title');

//设置新值到data中

$this->request->data('Post.title', 'New post!');


/**
 * Provides a read/write accessor for `$this->data`.  Allows you
 * to use a syntax similar to `CakeSession` for reading post data.
 *
 * ## Reading values.
 *
 * `$request->data('Post.title');`
 *
 * When reading values you will get `null` for keys/values that do not exist.
 *
 * ## Writing values
 *
 * `$request->data('Post.title', 'New post!');`
 *
 * You can write to any value, even paths/keys that do not exist, and the arrays
 * will be created for you.
 *
 * @param string $name,... Dot separated name of the value to read/write
 * @return mixed Either the value being read, or this so you can chain consecutive writes.
 */

返回首页