Chapter 8 associateUserToProject

Here’s my function :


public function associateUserToProject($user) {

        

        $sql = "INSERT INTO tbl_project_user_assignment (project_id,user_id) VALUES (:projectId, :userId)";

        $command = Yii::app()->db->createCommand($sql);

        $command->bindValue(":projectId", $this->id, PDO::PARAM_INT);

        $command->bindValue(":userId", $user->id, PDO::PARAM_INT);

        return $command->execute();

   

    }

And the error:

CDbException: CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘=‘1’ AND user_id=‘1’’ at line 1

Solved.It is not in this function