model:
class Art extends AppModel {
public $name = 'Art';
}
controller:
class ArtsController extends AppController {
public $name = 'Arts';
public function add(){
if($this->request->is('Post')){
pr($this->Art->save($this->request->data));
}
}
}
view: add.ctp
echo $this->Form->create('Post');
echo $this->Form->name('title');
echo $this->Form->end('Post');
database:
CREATE TABLE IF NOT EXISTS `arts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(25) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
using these code i attempt to save some random numbers into 'arts'
table, $this->Arts->save() return true but when I check the database
its empty.
I am able to use Art->find('all') and get the result after I manually
insert the data into table, so this rule out possibility of the model
is not connected to table.
on the same machine , i tried the blog tutorial and its able to add
the posts.
I cannot figure why i failed to save the data with even though i had
already reduced the code into its simplest form.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php