I am new to yii. With [color="#4169E1"]gii[/color] i tried to generate CRUD using [color="#FF0000"]CRUD[/color] generator but it throws a php error.
[size=“4”]PDO::__construct() [<a href=‘pdo.–construct’>pdo.–construct</a>]: [2002] An attempt was made to access a socket in a way forbidden by its (trying to connect via tcp://localhost:3306)[/size]
Any solution to this problem?
Following is the page it actually shows
PHP Error
PDO::__construct() [<a href=‘pdo.–construct’>pdo.–construct</a>]: [2002] An attempt was made to access a socket in a way forbidden by its (trying to connect via tcp://localhost:3306)
F:\xampp\htdocs\yii\framework\db\CDbConnection.php(389)
377 * @since 1.0.4
378 */
379 protected function createPdoInstance()
380 {
381 $pdoClass=‘PDO’;
382 if(($pos=strpos($this->connectionString,’:’))!==false)
383 {
384 $driver=strtolower(substr($this->connectionString,0,$pos));
385 if($driver===‘mssql’ || $driver===‘dblib’)
386 $pdoClass=‘CMssqlPdoAdapter’;
387 }
388 return new $pdoClass($this->connectionString,$this->username,
389 $this->password,$this->_attributes);
390 }
391
392 /**
393 * Initializes the open db connection.
394 * This method is invoked right after the db connection is established.
395 * The default implementation is to set the charset for MySQL and PostgreSQL database connections.
396 * @param PDO $pdo the PDO instance
397 */
398 protected function initConnection($pdo)
399 {
400 $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
401 if($this->emulatePrepare && constant(‘PDO::ATTR_EMULATE_PREPARES’))
Stack Trace
#0
- F:\xampp\htdocs\yii\framework\db\CDbConnection.php(389): PDO->__construct("mysql:host=localhost;dbname=testdb", "root", "password", array())
#1
- F:\xampp\htdocs\yii\framework\db\CDbConnection.php(340): CDbConnection->createPdoInstance()
#2
- F:\xampp\htdocs\yii\framework\db\CDbConnection.php(297): CDbConnection->open()
#3
- F:\xampp\htdocs\yii\framework\db\CDbConnection.php(275): CDbConnection->setActive(true)
#4
- F:\xampp\htdocs\yii\framework\base\CModule.php(372): CDbConnection->init()
#5
- F:\xampp\htdocs\yii\framework\base\CModule.php(86): CModule->getComponent("db")
#6
- F:\xampp\htdocs\yii\framework\gii\generators\crud\CrudCode.php(44): CModule->__get("db")
#7
- F:\xampp\htdocs\yii\framework\web\CFormModel.php(40): CrudCode->init()
#8
- F:\xampp\htdocs\yii\framework\gii\CCodeGenerator.php(149): CFormModel->__construct()
#9
- F:\xampp\htdocs\yii\framework\gii\CCodeGenerator.php(61): CCodeGenerator->prepare()
#10
- F:\xampp\htdocs\yii\framework\web\actions\CInlineAction.php(50): CCodeGenerator->actionIndex()
#11
- F:\xampp\htdocs\yii\framework\web\CController.php(300): CInlineAction->runWithParams(array("r" => "gii/crud"))
#12
- F:\xampp\htdocs\yii\framework\web\CController.php(278): CController->runAction(CInlineAction)
#13
- F:\xampp\htdocs\yii\framework\web\CController.php(257): CController->runActionWithFilters(CInlineAction, array())
#14
- F:\xampp\htdocs\yii\framework\web\CWebApplication.php(328): CController->run("")
#15
- F:\xampp\htdocs\yii\framework\web\CWebApplication.php(121): CWebApplication->runController("gii/crud")
#16
- F:\xampp\htdocs\yii\framework\base\CApplication.php(155): CWebApplication->processRequest()
#17
– F:\xampp\htdocs\map\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();