Afnan Bashir
Afnan Bashir

Reputation: 7429

CaseSenstive Table names

hi there i made track star application and everything works fine except for one issue that i face error CDbCommand failed to execute the SQL statement: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'devnmark_root.AuthAssignment' doesn't exist. The SQL statement executed was: SELECT * FROM 'AuthAssignment' WHERE userid=:userid

now this was automatically generated by Yii when i checked for if(Yii::app()->user->checkAccess('createUser',array('project'=>$model))) 18 { 19 $this->menu[] = array('label'=>'Add User To Project','url'=>array('adduser', 'id'=>$model->id)); 20 }

then i went to phpmyadmin and executed this query manually

SELECT * FROMAuthAssignmentWHERE userid=4 and there is error which says same that table does not exist.

if i use small case letter for table name then no error.

i executed same query on local wamp 's phpmyadmin same query does not show any error there so this is clear that there is error with my sql .any idea what can i do to solve?

Upvotes: 0

Views: 2211

Answers (5)

Jonauz
Jonauz

Reputation: 4133

For me this answer helped the most: original source.

In the authManager in config/main.php you can add lowercased names of the tables like this:

'components'=>array(
    'authManager'=>array(
        'defaultRoles'=>array('guest'),
        'class'=>'RDbAuthManager',
        'assignmentTable'=>'authassignment',
        'itemTable'=>'authitem',
        'rightsTable'=>'rights',
        'itemChildTable'=>'authitemchild',
),

Upvotes: 0

iltaf khalid
iltaf khalid

Reputation: 10328

I had the same problem of non-existent authassignment table, I had forgotten running the rights installation which in my case was by following URL i.e.

/index.php/rights/install

and then the setup was like a breeze and self explanatory :)

Upvotes: 0

renathy
renathy

Reputation: 5355

My local application was developed under Windows, howerver production is under Linux and I caused the same problem. For me it happened because of case sensitivity - table AuthAssignment in database was actually authassignment.

I have found two options to solve it: rename database table from authassignment to AuthAssignment or edit config file component section:

'components'=>array(
...
    'user'=>array(...
    ),
    'authManager'=>array(
     ...
     'assignmentTable'=>'authassignment' //THIS LINE SOLVED MY PROBLEM
),

Upvotes: 1

Dimitre Radoulov
Dimitre Radoulov

Reputation: 28010

You may try to set the system variable *lower_case_table_names* to 1.

Upvotes: 1

William Stearns
William Stearns

Reputation: 479

I suggest you hitting up SQL_MODE documentation for setting your final options. http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html

For testing you can just do a:

SET sql_mode = '';

Or adjust your command line:

--sql-mode=""

Upvotes: 1

Related Questions