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.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to