Jervyn Paller
Jervyn Paller

Reputation: 73

Error: SQLSTATE[42S22]: Column not found in live server

What happen to my code, after uploading to godaddy server it has an error but in localhost their is no error.

enter image description here

public function activate($activation_key='') {

        $userData = $this->Users->find('all')->where(['activation_key' => $activation_key,'status' => 0 ])->first();

            if( !empty($userData) ){
               $activeStatus = 1;
               $status = $this->Users->updateAll(array('Users.status' => 
       $activeStatus), array('Users.id' => $userData->id));

      //// additional code
    }
    }

stack trace error is on this line

 $status = $this->Users->updateAll(array('Users.status' =>
   $activeStatus), array('Users.id' => $userData->id));

Needing your help

Upvotes: 1

Views: 57

Answers (1)

kicaj
kicaj

Reputation: 2968

You syntax is incorrect:

UPDATE `users` SET `Users`.`status`...

Should be:

UPDATE `users` AS  `Users` SET `Users`.`status`...

Remove Users aliases from updateAll.

Upvotes: 1

Related Questions