Hello, my project team needs a scheduler that uses timesheets and is written in PHP, so instead of making one completely from scratch I decided to download a PHP web application called MyT that does a lot of the features for me. It uses the Yii framework, and I’m curious as to how do I connect it with the SQL database we have, note that this is not a mySQL database, just a microsoft sql database. I inspected the contents of the PHP package that MyT comes in and I have found a config folder which holds two php files, main_install and main_sample. Looking through it I’ve tried numerous ways to connect to the database but to no avail. I keep getting the error message “CDbConnection failed to open the DB connection.” If anyone can point me in the right direction I’d really appreciate it.
I’m assuming the main_sample is the one I need to configure. The website for this web app stated that all I needed to do was set write permissions on a few folder and to just go through the installation via the web app, but that also didn’t work. That’s why I’m assuming I need to do some configuration, but here is the code for the two files, main_install, and main_sample:
[size="5"]main_sample[/size]
<?php
return array(
'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
'name' => '<APP_NAME>',
'preload' => array('log'),
// autoloading model and component classes
'import' => array(
'application.models.*',
'application.components.*',
'ext.easyimage.EasyImage',
'ext.EExcelView',
'ext.TaskExcelView',
),
// i18n
'language' => '<APP_LANGUAGE>',
'sourceLanguage' => 'en',
'theme' => 'classic',
'modules' => array(
'gii' => array(
'class' => 'system.gii.GiiModule',
'password' => 'Ah!',
'ipFilters' => array('127.0.0.1', '::1', '*'),
),
),
// application components
'components' => array(
'widgetFactory' => array(
'widgets' => array(
'CLinkPager' => array(
'cssFile' => false,
'header' => false
)
)
),
'user' => array(
'class' => 'RWebUser',
'allowAutoLogin' => true,
),
'cache' => array(
'class' => 'system.caching.CFileCache',
),
'counter' => array(
'class' => 'ext.mySession.UserCounter',
),
'mail' => array(
'class' => 'ext.yii-mail.YiiMail',
'transportType' => 'php',
'logging' => false,
'dryRun' => false
),
/* -- REWRITE URL --
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:authItem>/<action:\w+>/<id:(?:[a-zA-Z0-9]+[ ]?)+[a-zA-Z0-9]+>' => '<controller>/<action>', //this is only for auth manager
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
'<controller:charge>/<action:create>/<month:[\w-]+>/<user:\d+>/<project:\d+>' => '<controller>/<action>', //custom rule for months
),
),
-- REWRITE URL -- */
'db' => array(
'connectionString' => '<DSN>',
'emulatePrepare' => true,
'username' => '<DATABASE_USER>',
'password' => '<DATABASE_PASS>',
'tablePrefix' => '<DATABASE_PREFIX>',
'charset' => 'utf8',
'enableProfiling' => true,
'enableParamLogging' => true,
),
'authManager' => array(
'class' => 'CDbAuthManager',
'connectionID' => 'db',
'itemTable' => '{{auth_item}}',
'itemChildTable' => '{{auth_item_child}}',
'assignmentTable' => '{{auth_assignment}}',
),
'errorHandler' => array(
'errorAction' => 'site/error',
),
'log' => array(
'class' => 'CLogRouter',
'routes' => array(
array(
'class' => 'CFileLogRoute',
'levels' => 'error, warning',
),
array(
'class' => 'ext.yii-debug-toolbar.YiiDebugToolbarRoute',
'ipFilters' => array('127.0.0.1', '*'),
),
),
),
'session' => array(
'class' => 'ext.mySession.DbHttpSession',
'connectionID' => 'db',
'sessionTableName' => '{{session}}',
'autoCreateSessionTable' => false,
'timeout' => 3600
),
'format' => array(
'class' => 'ELocalizedFormatter',
),
'easyImage' => array(
'class' => 'application.extensions.easyimage.EasyImage'
),
'mega' => array(
'class' => 'application.extensions.yii-mega-api.Mega'
),
'messages' => array(
'class' => 'CPhpMessageSource',
'forceTranslation' => true,
'language' => 'en',
'cachingDuration' => 604800, // 1 week
),
),
'params' => require(dirname(__FILE__) . '/params.php'),
);
[size="5"]main_install[/size]
<?php
return array(
'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
'name' => 'MyT Installer',
'defaultController' => 'install/index',
// preloading 'log' component
'preload' => array('log'),
// autoloading model and component classes
'import' => array(
'application.models.*',
'application.components.*',
),
// i18n
'language' => 'en',
'sourceLanguage' => 'en',
'theme' => 'classic',
// application components
'components' => array(
'widgetFactory' => array(
'widgets' => array(
'CLinkPager' => array(
'cssFile' => false,
'header' => false
)
)
),
'cache' => array(
'class' => 'system.caching.CFileCache',
),
'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',
),
*/
),
),
'format' => array(
'class' => 'ELocalizedFormatter',
),
'messages' => array(
'class' => 'CPhpMessageSource',
'forceTranslation' => true,
'language' => 'en',
),
),
);