Anupam
Anupam

Reputation: 1178

Codeignitor Error Number: 1066 "Not unique table/alias"

What I am trying to do

            $this->form_validation->set_rules('username', $this->lang->line('signup_username'), 'required|callback__usernameRegex|min_length[5]|max_length[15]|is_unique[users.username]',
            array(
                'required'      => $this->lang->line('signup_username_missing'),
                'is_unique'     => $this->lang->line('signup_username_exists')
            )
        );
        $this->form_validation->set_rules('email', $this->lang->line('signup_email'), 'required|valid_email|is_unique[users.email]',
            array(
                'required'      => $this->lang->line('signup_email_missing'),
                'is_unique'     => $this->lang->line('signup_email_exists')
            )
        );

username and email should be unique as expected so I'm using is_unique[users.username] and is_unique[users.email] to check for it, but as soon as I run

$this->form_validation->run()

I am getting error 1066

Not unique table/alias: 'sdy_users'

and query it returns is

SELECT * FROM sdy_users, sdy_users WHERE username = 'testu' AND email = '[email protected]' LIMIT 1

it is somehow adding the table name twice! Earlier it was working but I am failing to understand what is wrong!

Upvotes: 1

Views: 75

Answers (1)

Nadeem Ijaz
Nadeem Ijaz

Reputation: 599

there is a problem in your query please correct it

SELECT * FROM sdy_users, sdy_users WHERE username = 'testu' AND email = '[email protected]' LIMIT 1

why are you using this twice ?? sdy_users, sdy_users ?? because of this system showing this error Not unique table/alias: 'sdy_users'

Upvotes: -2

Related Questions