是用yiic的问题

第一次使用yii 在使用yiic 创建 模型的时候 报错,说没有找到驱动。但是pdo_mysql与pdo我已经开启了的。

确实找到是什么问题了,有没有朋友遇到过类似的问题的?请提点。

能贴出错误代码吗?好让大家分析

你也可以自己写测试代码看看是不是真的有PDO。

比如说,运行一下这个




<?php

$pdo = new PDO;



看有没有错误

我测试过,PDO确实是有的。不过通过命令行的方式来执行 model 的创建 就会出错,

说没有找到驱动,很纳闷。

错误提示就是没有找到驱动。。

报错的位置是 CDbConnection 的 open函数

$this->_pdo=$this->createPdoInstance();

在调用这里的时候出错。

protected function createPdoInstance()


{


	&#036;pdoClass='PDO';


	if((&#036;pos=strpos(&#036;this-&gt;connectionString,':'))&#33;==false)


	{


		&#036;driver=strtolower(substr(&#036;this-&gt;connectionString,0,&#036;pos));


		if(&#036;driver==='mssql' || &#036;driver==='dblib')


			&#036;pdoClass='CMssqlPdoAdapter';


	}


	return new &#036;pdoClass(&#036;this-&gt;connectionString,&#036;this-&gt;username,


								&#036;this-&gt;password,&#036;this-&gt;_attributes);


}

在new $pdoClass的时候就出错了

参数全没有问题,只是没有找到驱动。

找到问题所在了,因为我是实用的wamp环境。

所以我在shell 创建 model 的时候 php.ini文件是实用的另外一个。所以造成了虽然 wamp环境开启了pdo_mysql 但是 php shell的配置文件并未开启pdo_mysql 所以造成没有找到驱动的问题,请实用wamp环境的新手兄弟注意哦!