CDbException

Hi,

I am newbie in Yii. And during installation of Yii extension User Management but during this I am getting this error. Please help me I am not getting installation page. I have followed all steps given in tutorial.

CDbException

CDbCommand failed to execute the SQL statement: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘testdrive.translation’ doesn’t exist. The SQL statement executed was: select message, translation from translation where language = :language and category = :category

/opt/lampp/htdocs/yii/framework/db/CDbCommand.php(528)

516 return $result;

517 }

518 catch(Exception $e)

519 {

520 if($this->_connection->enableProfiling)

521 Yii::endProfile(‘system.db.CDbCommand.query(’.$this->getText().$par.’)’,‘system.db.CDbCommand.query’);

522 $errorInfo = $e instanceof PDOException ? $e->errorInfo : null;

523 $message = $e->getMessage();

524 Yii::log(Yii::t(‘yii’,‘CDbCommand::{method}() failed: {error}. The SQL statement executed was: {sql}.’,

525 array(’{method}’=>$method, ‘{error}’=>$message, ‘{sql}’=>$this->getText().$par)),CLogger::LEVEL_ERROR,‘system.db.CDbCommand’);

526 if(YII_DEBUG)

527 $message .= '. The SQL statement executed was: '.$this->getText().$par;

528 throw new CDbException(Yii::t(‘yii’,‘CDbCommand failed to execute the SQL statement: {error}’,

529 array(’{error}’=>$message)),(int)$e->getCode(),$errorInfo);

530 }

531 }

532

533 /**

534 * Builds a SQL SELECT statement from the given query specification.

535 * @param array $query the query specification in name-value pairs. The following

536 * query options are supported: {@link select}, {@link distinct}, {@link from},

537 * {@link where}, {@link join}, {@link group}, {@link having}, {@link order},

538 * {@link limit}, {@link offset} and {@link union}.

539 * @return string the SQL statement

540 * @since 1.1.6

Stack Trace

#0

  • /opt/lampp/htdocs/yii/framework/db/CDbCommand.php(390): CDbCommand->queryInternal("fetchAll", array(2), array())

#1

– /opt/lampp/htdocs/mydemo/protected/modules/user/models/Yum.php(131): CDbCommand->queryAll()

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

127 $command->bindValue(’:category’,$category);

128 $command->bindValue(’:language’,$language);

129

130 $messages=array();

131 foreach($command->queryAll() as $row)

132 $messages[$row[‘message’]]=$row[‘translation’];

133 }

134

135 if(Yii::app()->cache)

136 Yii::app()->cache->set($cache_id, $messages);

#2

– /opt/lampp/htdocs/mydemo/protected/modules/user/controllers/YumInstallController.php(459): Yum::t("User management module is not in Debug Mode")

454 ‘friendshipTable’ => Yum::resolveTableName($this->module->friendshipTable, Yii::app()->db),

455 ‘actionTable’ => Yum::resolveTableName($this->module->actionTable, Yii::app()->db),

456 ));

457 }

458 } else {

459 throw new CException(Yum::t(‘User management module is not in Debug Mode’));

460 }

461 }

462

463 public function actionIndex()

464 {

#3

  • /opt/lampp/htdocs/yii/framework/web/actions/CInlineAction.php(50): YumInstallController->actionInstall()

#4

  • /opt/lampp/htdocs/yii/framework/web/CController.php(309): CInlineAction->runWithParams(array())

#5

  • /opt/lampp/htdocs/yii/framework/web/filters/CFilterChain.php(134): CController->runAction(CInlineAction)

#6

  • /opt/lampp/htdocs/yii/framework/web/filters/CFilter.php(41): CFilterChain->run()

#7

  • /opt/lampp/htdocs/yii/framework/web/CController.php(1146): CFilter->filter(CFilterChain)

#8

  • /opt/lampp/htdocs/yii/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(CFilterChain)

#9

  • /opt/lampp/htdocs/yii/framework/web/filters/CFilterChain.php(131): CInlineFilter->filter(CFilterChain)

#10

  • /opt/lampp/htdocs/yii/framework/web/CController.php(292): CFilterChain->run()

#11

  • /opt/lampp/htdocs/yii/framework/web/CController.php(266): CController->runActionWithFilters(CInlineAction, array("accessControl"))

#12

  • /opt/lampp/htdocs/yii/framework/web/CWebApplication.php(276): CController->run("")

#13

  • /opt/lampp/htdocs/yii/framework/web/CWebApplication.php(135): CWebApplication->runController("user/install")

#14

  • /opt/lampp/htdocs/yii/framework/base/CApplication.php(162): CWebApplication->processRequest()

#15

– /opt/lampp/htdocs/mydemo/index.php(13): CApplication->run()

08 defined(‘YII_DEBUG’) or define(‘YII_DEBUG’,true);

09 // specify how many levels of call stack should be shown in each log message

10 defined(‘YII_TRACE_LEVEL’) or define(‘YII_TRACE_LEVEL’,3);

11

12 require_once($yii);

13 Yii::createWebApplication($config)->run();

2012-06-01 22:36:29 Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 Yii Framework/1.1.10

Read the database error that it gives you:

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘testdrive.translation’ doesn’t exist. The SQL statement executed was: select message, translation from translation where language = :language and category = :category

Table “testdrive.translation” doesn’t exist.

Dustin Oprea

Thank you Dustin. I also understand that this table is not exist. During installation of User Management extension these table suppose to be created automatically. But it is not creating. I am following the exact steps given on YII framework site. So my question is do these tables will create automatically or I will have to do some extra steps for this.

Hi Manis,

Did you follow /user/docs/install_tutorial.txt from downloaded extension?

And please notice there’s a more proper Extensions forum for such kind of questions.

And even there’s a specific thread regarding User Management module

Regards,

Yuga

Hiii to all

I am newbie in Yii . actually when i try to connect my login form to data base its show

CDbException

CDbCommand failed to execute the SQL statement: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘final.translation’ doesn’t exist. The SQL statement executed was: select message, translation from translation where language = :language and category = :category

Error. plz help me to solve this problem

This error means what it says - there’s no translation table at final db.

Did you check this table exists?

i check it properly . the table exits.

What do you have in your config file regarding db connection(s)?

Do you use a property connection?

Which way you request looks like?

<?php

// uncomment the following to define a path alias

// Yii::setPathOfAlias(‘local’,‘path/to/local-folder’);

// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.

return array(

'basePath' =&gt; dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',


'name' =&gt; 'Sarathi',





// preloading 'log' component


'preload' =&gt; array('log', 'bootstrap'),


// autoloading model and component classes


'import' =&gt; array(


    'application.models.*',


    'application.components.*',


    


    'application.modules.user.models.*',


    'application.modules.profile.models.*',


),





'modules' =&gt; array(


    // uncomment the following to enable the Gii tool





    'gii' =&gt; array(


        'class' =&gt; 'system.gii.GiiModule',


        'password' =&gt; 'sarathi',


        // If removed, Gii defaults to localhost only. Edit carefully to taste.


        'ipFilters' =&gt; array('127.0.0.1', '::1'),


        'generatorPaths' =&gt; array('bootstrap.gii',),


    ),


    


    'user' =&gt; array(


        'debug' =&gt; false,


        'userTable' =&gt; 'Users',


        'translationTable' =&gt; 'translation',


        


    ),


    


    'profile' =&gt; array(


        


        'profileTable' =&gt; 'profile',


        


    ),


    


    


    


),


// application components


'components' =&gt; array(


    'session' =&gt; array(


        'timeout' =&gt; 864000,


    ),


    'user' =&gt; array(


        'class' =&gt; 'application.modules.user.components.YumWebUser',


        'allowAutoLogin' =&gt; true,


        'autoRenewCookie' =&gt; true,


        'authTimeout' =&gt; 31557600,


        'loginUrl' =&gt; array('/'),


        'returnUrl' =&gt; array('//log/pending'),            


    ),


    'cache' =&gt; array(


        'class' =&gt; 'system.caching.CMemCache',


        'servers' =&gt; array(


            array('host' =&gt; 'localhost', 'port' =&gt; 11211, 'weight' =&gt; 50),


            array('host' =&gt; 'localhost', 'port' =&gt; 11211, 'weight' =&gt; 50),


        ),


    ),


    //'cache' =&gt; array('class' =&gt; 'system.caching.CFileCache'),


    'import' =&gt; array(


        'application.modules.user.models.*',


    ),


    


    'swiftMailer' =&gt; array(


        'class' =&gt; 'ext.swiftMailer.SwiftMailer',


    ),

// ‘bootstrap’=>array(

// ‘class’=>‘ext.bootstrap.components.Bootstrap’, // assuming you extracted bootstrap under extensions

// ),

    // uncomment the following to enable URLs in path-format





    'urlManager' =&gt; array(


        'urlFormat' =&gt; 'path',            


        'rules' =&gt; array(


            'referral/&lt;email&gt;'=&gt;'site/refer',


            '&lt;controller:&#092;w+&gt;/&lt;id:&#092;d+&gt;' =&gt; '&lt;controller&gt;/view',


            '&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;/&lt;id:&#092;d+&gt;' =&gt; '&lt;controller&gt;/&lt;action&gt;',


            '&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;' =&gt; '&lt;controller&gt;/&lt;action&gt;',               


        ),


    ),


    // uncomment the following to use a MySQL database





   'db' =&gt; array(


        'connectionString' =&gt; 'mysql:host=localhost;dbname=doit',


        'emulatePrepare' =&gt; true,


        'username' =&gt; 'root',


        'password' =&gt; '',


        'charset' =&gt; 'utf8',


        'tablePrefix' =&gt; '',


    ),


    'errorHandler' =&gt; array(


        // use 'site/error' action to display errors


        'errorAction' =&gt; 'site/error',


    ),


    'log' =&gt; array(


        'class' =&gt; 'CLogRouter',


        'routes' =&gt; array(


            array(


                'class' =&gt; 'CFileLogRoute',


                'levels' =&gt; 'error, warning',


            ),


        // uncomment the following to show log messages on web pages


        /*


          array(


          'class'=&gt;'CWebLogRoute',


          ),


         */


        ),


    ),


),


// application-level parameters that can be accessed


// using Yii::app()-&gt;params['paramName']


'params' =&gt; array(


    'version' =&gt; 5.2,


    // this is used in contact page


    'adminEmail' =&gt; 'rupamranjan007@gmail.com',


    


),

);

?>

//this is my config

So, you have db configured this way (please you editor code formatting next time):





'db' => array(

	'connectionString' => 'mysql:host=localhost;dbname=doit',

	'emulatePrepare' => true,

	'username' => 'root',

	'password' => '',

	'charset' => 'utf8',

	'tablePrefix' => '',

),



Is it configured properly?

What is strange, from your request error it looks like your db should be named final.

If your db connection is correct, which way do you make you query?

i am sorry for that error. but i try to change the database table. i think i have problem in the final db table . so i create another table ‘doit’.at that time i just paste this config…But after this also i got that error.

You still didn’t post the code for your request.

Can you run the query successfully directly in mysql?

CDbException

CDbCommand failed to execute the SQL statement: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘doit.translation’ doesn’t exist. The SQL statement executed was: select message, translation from translation where language = :language and category = :category

C:\wamp\www\final\framework\db\CDbCommand.php(528)

516 return $result;

517 }

518 catch(Exception $e)

519 {

520 if($this->_connection->enableProfiling)

521 Yii::endProfile(‘system.db.CDbCommand.query(’.$this->getText().$par.’)’,‘system.db.CDbCommand.query’);

522 $errorInfo = $e instanceof PDOException ? $e->errorInfo : null;

523 $message = $e->getMessage();

524 Yii::log(Yii::t(‘yii’,‘CDbCommand::{method}() failed: {error}. The SQL statement executed was: {sql}.’,

525 array(’{method}’=>$method, ‘{error}’=>$message, ‘{sql}’=>$this->getText().$par)),CLogger::LEVEL_ERROR,‘system.db.CDbCommand’);

526 if(YII_DEBUG)

527 $message .= '. The SQL statement executed was: '.$this->getText().$par;

528 throw new CDbException(Yii::t(‘yii’,‘CDbCommand failed to execute the SQL statement: {error}’,

529 array(’{error}’=>$message)),(int)$e->getCode(),$errorInfo);

530 }

531 }

532

533 /**

534 * Builds a SQL SELECT statement from the given query specification.

535 * @param array $query the query specification in name-value pairs. The following

536 * query options are supported: {@link select}, {@link distinct}, {@link from},

537 * {@link where}, {@link join}, {@link group}, {@link having}, {@link order},

538 * {@link limit}, {@link offset} and {@link union}.

539 * @return string the SQL statement

540 * @since 1.1.6

can you make the same query at mysql command line / phpmyadmin?

If it helps, I ran this SQL statement and it seems to have gotten me past the missing translation table.




CREATE TABLE IF NOT EXISTS translation (

            `message` varbinary(255) NOT NULL,

            `translation` varchar(255) NOT NULL,

            `language` varchar(5) NOT NULL,

            `category` varchar(255) NOT NULL,

            PRIMARY KEY (`message`,`language`,`category`)

          ) ENGINE=InnoDB DEFAULT CHARSET=utf8;



Hi, I have a following message:

CDbCommand falló al ejecutar la sentencia SQL: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘pbis_meta.pbi_security_user’ doesn’t exist. The SQL statement executed was: SELECT * FROM pbis_meta.PBI_SECURITY_USER

My dabase server is SQLSERVER 2008r2 anybody can help me?

my string connection in main.php file is:

db’=>array(

 'connectionString' =&gt; 'sqlsrv:server=192.168.10.29&#092;SQLEXPRESS;database=PBIS',


 'username' =&gt; 'MYUSER',


 'password' =&gt; 'MYPASS',

),

Thanks.

J.