0

I really don't know what causes this error.

    CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]: 
    General error: 1 table 'YiiSession' already exists. The SQL statement executed was: 
    CREATE TABLE 'YiiSession' (
    "id" CHAR(32) PRIMARY KEY,
    "expire" integer,
    "data" BLOB
    ) 

Is it in the server or in yii.. but i guess it is in the yii part. but what configurations did i miss? i'm not really familiar with yii because im new to it. any help please? Thanks in advance

UPDATE: I check YiiSession in my database but it is not in there...

2 Answers 2

2

Delete the runtime folder. Because runtime folder is used by the system for various tasks: session, logging etc. It is also in the runtime folder that YiiSession table is created

Sign up to request clarification or add additional context in comments.

Comments

1

In case anyone is still referencing this - the more complete answer is that Yii uses a SQLite3 database by default if you don't specify a connection string in your (CDbHttpSession) session config. This SQLite db is created in the runtime folder. (Which is why deleting the contents of the runtime folder works - you actually only need to delete the session-x.x.xx.db file.) If you want to use the same database you are using for your main connection, add:

 'connectionID'=>'db',

to your session config. It's also recommended for production use you set autoCreateSessionTable to false, which will also prevent the error - you just need to make sure you deploy the SQLite db or set up the proper table in your main db. see here

By default, it will use an SQLite3 database named 'session-YiiVersion.db' under the application runtime directory. You can also specify connectionID so that it makes use of a DB application component to access database.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.