Hi all,
I am trying to update a column for some record in the database, but because of there is a another unique column exists in the table, Phalcon model fails to update that record.
$allUsers = Users::find();
foreach ($allUsers as $user){
$user->token = $this->someToken;
$user->update();
}
It returns this error:
Unique violation: 7 ERROR: duplicate key value violates unique constraint "user_name_unique"
Table structure:
CREATE TABLE public.users
(
id integer NOT NULL DEFAULT nextval('users_id_seq'::regclass),
user_name text,
user_job_position character varying(100),
first_name character varying(50),
last_name character varying(100),
last_activity time without time zone,
ip_address character varying(15),
token text,
token_hash text,
CONSTRAINT user_name_unique UNIQUE (user_name)
)
Am I doing something wrong ?