Unable To Handle Cdbconnection Error In Production Mode In Yii


<?php $this->widget('bootstrap.widgets.Tbnavbar',array(

    'brand' => 'RateMonk',

    'fixed' => false,

    'items'=>array(

        array(

        'class' => 'bootstrap.widgets.TbMenu',

        'items' => array(

        array('label'=>'Home','url'=>array('/dashboard'),'visible'=>(!Yii::app()->user->isGuest&&!Yii::app()->getModule('user')->isAdmin())),

    )),

  ),

)); ?>

I dont want to display cdbconnection error in production mode but in the main.php I have used user module which display cdbconnection in yii can any one suggest how to handle it.I have disable the DEBUG in index.php and I am using site controller with action error to handle the error.

paste your config/main.php and index.php

My config/main.php


 <?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'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

	'name'=>'TechChef',

	'defaultController' =>'user/login',

	// preloading 'log' component

	'preload'=>array('log','bootstrap'),


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

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

        'application.modules.user.components.*'

	),


	'modules'=>array(

		// uncomment the following to enable the Gii tool


		'gii'=>array(

			'class'=>'system.gii.GiiModule',

			'password'=>'admin123',

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

			'ipFilters'=>array('127.0.0.1','::1'),


			'generatorPaths'=>array(

	        	'bootstrap.gii', // since 0.9.1

	        ),

		),

		'dashboard' => array(

			'debug' => true,

			'portlets' => array(

				'TotalFeedback' => array('class' => 'TotalFeedback', 'visible' => true, 'weight' => 0,'column'=>0),

				'QuestionRating' => array('class' => 'QuestionRating', 'visible' => true, 'weight' => 1,'column'=>1),

			),

		),

		'user'=>array(

            # encrypting method (php hash function)

            'hash' => 'md5',


            # send activation email

            'sendActivationMail' => true,


            # allow access for non-activated users

            'loginNotActiv' => false,


            # activate user on registration (only sendActivationMail = false)

            'activeAfterRegister' => false,


            # automatically login from registration

            'autoLogin' => true,


            # registration path

            'registrationUrl' => array('/user/registration'),


            # recovery password path

            'recoveryUrl' => array('/user/recovery'),


            # login form path

            'loginUrl' => array('/user/login'),


            # page after login

            'returnUrl' => array('/user/profile'),


            # page after logout

            'returnLogoutUrl' => array('/user/login'),

        ),

	),


	// application components

	'components'=>array(

		 'user'=>array(

            // enable cookie-based authentication

            'class' => 'WebUser',

            'allowAutoLogin'=>true,

            'loginUrl' => array('/user/login'),

        ),

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

		'urlManager'=>array(

			'urlFormat'=>'path',

			 'showScriptName'=>false,

	 		 'caseSensitive'=>false,

			'rules'=>array(

				/*'questionset/<id:\d+>/<title:.*?>'=>'questionset/view',

				'questionset/<tag:.*?>'=>'questionset/index',*/


				// REST patterns

		        array('api/list', 'pattern'=>'api/<model:\w+>', 'verb'=>'GET'),

		        array('api/view', 'pattern'=>'api/<model:\w+>/<id:\d+>', 'verb'=>'GET'),

		        array('api/update', 'pattern'=>'api/<model:\w+>/<id:\d+>', 'verb'=>'PUT'),

		        array('api/delete', 'pattern'=>'api/<model:\w+>/<id:\d+>', 'verb'=>'DELETE'),

		        array('api/create', 'pattern'=>'api/<model:\w+>', 'verb'=>'POST'),


		        '<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

			),

		),


		'bootstrap' => array(

		    'class' => 'ext.booster.components.Bootstrap',

		),

		// 'db'=>array(

		// 	'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',

		// ),

		// uncomment the following to use a MySQL database

		'db'=>array(

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

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => '',

			'charset' => 'utf8',

			'tablePrefix' => 'tbl_',

		),

		'errorHandler'=>array(

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

			'errorAction'=>'site/error',

		),

		'log'=>array(

			'class'=>'CLogRouter',

			'routes'=>array(

				array(

					'class'=>'CFileLogRoute',

					'levels'=>'error, warning',

				),


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

				// array(

				// 	'class'=>'CWebLogRoute',

				// ),

			),

		),

	),


	// application-level parameters that can be accessed

	// using Yii::app()->params['paramName']

	'params'=>array(

		// this is used in contact page

		'adminEmail'=>'webmaster@example.com',

	),

);?>

My index.php




<?php


// change the following paths if necessary

$yii=dirname(__FILE__).'/../yii/framework/yii.php';

$config=dirname(__FILE__).'/protected/config/main.php';


// remove the following lines when in production mode

// defined('YII_DEBUG') or define('YII_DEBUG',true);

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

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);


require_once($yii);

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

?>



Sir ,

waiting for your reply

everything is in order looks good to me. its weird why is it displaying the errors

try this put it in your index.php


error_reporting(0);