I’ve created a database using SQL Server 2005, and want to create some models for Yii to reflect the structure.
When I go to run yiic, I get the following error after typing "model tbl_pages":
PHP Warning: YiiBase::include(PDO.php): failed to open stream: No such file or
directory in C:\xampplite\sites\yii\framework\YiiBase.php on line 338
I’ve made sure my intstallation of Apache is pointing to the correct PHP.ini, and that config has PDO running & for MSSQL. When I run PHPINFO() inside a controller within my Yii application, it tells me PDO is enabled as well as:
PDO Driver for MSSQL DB-lib enabled - Flavour: MSSQL_70
So, my webserver is running PDO as anticipated and I’ve setup the connection string in main.php for SQL Server, so that should work as expected.
I’ve done a search for PDO.php and was unable to find any such file. I’m running the latest stable version of 1.0 that’s available.
Does anyone know other reason why YIIC can’t find PDO.php?
yii tries to load PDO.php because of the autoloader. if a class is unkown within the script execution, yii tries to load a php file that looks like <classname>.php from the include path. It seems you still have a configuration problem with your apache and php. You could create a test.php file with just
OK. I’ve done that and while I get an error, it seems to confirm it can find PDO.
PHP Error
Description
PDO::__construct() expects at least 1 parameter, 0 given
Could it be that YIIC is not using the correct PHP.ini?
UPDATE: I was correct in my suspicions (which would’ve been confirmed if I’d seen andy_s’s comment before I replied - cheers!) I have PHP running for Apache and for IIS, both using different INI files. Apache was running via the XAMP PHP configs, yet YIIC was running via the IIS configs. I’ve resolved this.
So, having YIIC working properly with a working PHP.INI, I’ve created a model and a controller from a SQL Server which both work perfectly. Brilliant!