array(
Book => array(
[name] => 'bla bla'
)
)
so when you save it in the session variable "book", you must save the
new title as "book.Book.title", then the title will be placed inside
the Book array in the session.
Enjoy,
John
On Jan 6, 11:27 am, aveev <nashrullah_a...@yahoo.com> wrote:
> Hi, this is a newbie question
> I'd like to save the data passed from the session variable to the table.
>
> Here's the table I have
> CREATE TABLE IF NOT EXISTS `books` (
> `id` int(20) unsigned NOT NULL AUTO_INCREMENT,
> `name` varchar(30) NOT NULL,
> `title` varchar(20) NOT NULL,
> PRIMARY KEY (`id`)
> )
>
> Here's the view to add a book
> app/views/books
> <?
> echo $form->create('Book');
> echo $form->input('name');
> echo $form->end('Save Book');
> ?>
> There's only one form input, that is for the book name.
> Here's the controller I have:
> class BooksController extends AppController {
>
> function add() {
> if(!empty($this->data)) {
> $this->Session->write('book',$this->data);
>
> $this->Session->write('book.title','NEW BOOK');
> debug($this->Session->read('book'));
> $this->Book->save($this->Session->read('book'));
> }
> }
> }
>
> in the add function, I hardcodingly write book title to the session, save
> all the session data using save method. i hope that all the fields including
> book title will be saved to the table.
> Strangely, the book table only contains id and name, not the title field
> (it stays empty).
> Here's I've got from the debug
>
> Array
> (
> [Book] => Array
> (
> [name] => zz
> )
>
> [title] => NEW BOOK
> )
>
> So, how can I set one field for a table using the session variable ?
> Any help would be appreaciated..
> Thanks
>
> I use cakephp 1.2
>
> --
> View this message in context:http://old.nabble.com/Writing-session-variable-tp27026816p27026816.html
> Sent from the CakePHP mailing list archive at Nabble.com.
No comments:
Post a Comment