lokeshjain2008
lokeshjain2008

Reputation: 1891

Save is not working as expected in cakephp 1.2

using cakePhp for an existing product they have old version 1.2. I just started using CakePhp. I tried to save some data to the table. here is my code.

function add(){

        //echo $id;
        pr($this->data);
        if(!empty($this->data)){
            $this->User->create();
            if($this->User->save($this->data)){
                debug($this->User->validationErrors);
                exit();
                $this->Session->setFlash("Data saved man");
                $this->redirect(array('action'=>'index',2));
            }
        }
    }

Below is debug data.

Array
(
    [user] => Array
        (
            [first_name] => hello
            [last_name] => man
            [email] => [email protected]
            [password] => 123
            [created_at] => Array
                (
                    [month] => 01
                    [day] => 17
                    [year] => 2014
                    [hour] => 08
                    [min] => 56
                    [meridian] => am
                )

            [modified_at] => Array
                (
                    [month] => 01
                    [day] => 17
                    [year] => 2014
                    [hour] => 08
                    [min] => 56
                    [meridian] => am
                )

        )

)
app\controllers\users_controller.php (line 36)
Array
(
)

(default) 0 query took ms
Nr  Query   Error   Affected    Num. rows   Took (ms).

I have no clue why data is not saving to database. I need to get it work for version 1.2. thanks

Upvotes: 0

Views: 218

Answers (1)

Hazem Mohamed
Hazem Mohamed

Reputation: 564

I think user key should have capital U as User. Check your view code to make sure that the model passed to $form->create('User') not 'user'

Upvotes: 3

Related Questions