views:

382

answers:

1

Hi,

CakePHP is driving me nuts!

Here is my code:

if($this->Page->save($datavalue))
{
$this->Session->setFlash('Page content updated successfully.');
}
else
{
$this->Session->setFlash('Page content was not updated.');
}

it always says updated successfully, but nothing is updated in the database. Here is the content of $datavalue:

Array
(
    [Page] => Array
        (
            [id] => 1
            [name] => home
            [title] => Home page1
            [meta_keywords] => keyword1
            [meta_description] => this is home page
            [content] => home page content
            [sidebar] => sidebar content
        )

)

I am new to CakePHP, can you please give me a general idea of what could be wrong with it?

Thanks in advance.

-happyhardik

Here is my model code:

<?php

class Page extends AppModel
{   
    var $name='Page';
    var $useTable = false;    
}
?>

Hope this helps! I tried to add this two lines before save, in a hope that it will help:

$this->Page->set($datavalue);
$this->Page->id = $id;

but none of them helped.


Here is the table structure:

id               int(10) UNSIGNED  auto_increment  Primary
name             varchar(250) 
title            varchar(250) 
meta_keywords    text   
meta_description text
content          text 
sidebar          text
created          datetime
modified         datetime

Let me know, if need any more information. Thanks for reading.

+3  A: 
var $useTable = false;

Well, you're not using any table, which makes save() pretty much a NOOP. :-)

Remove that line and you should be fine.

deceze
Thanks for the answer Deceze. It worked.
happyhardik