bruno
(bruno_)
July 21, 2009, 10:31am
1
Hi,
I’ve two web applications. The first is an intial web application just created by the webapp command. the second is a copy of the blog demo. I’m trying to add a categories management to this project. So I’ve created a table [font=“Courier New”]category[/font] and now want to create the model by command line. Unfortunately, it doesn’t work.
I have this error message when trying to run [font="Courier New"]yiic[/font]. Then message appears as an html document in the command prompt:
It happens here : J:\Developpement\serveur\yii\framework\YiiBase.php(316)
00307: public static function autoload($className)
00308: {
00309: // use include so that the error PHP file may appear
00310: if(isset(self::$_coreClasses[$className]))
00311: include(YII_PATH.self::$_coreClasses[$className]);
00312: else if(isset(self::$_classes[$className]))
00313: include(self::$_classes[$className]);
00314: else
00315: {
00316: include($className.'.php');
00317: return class_exists($className,false) || interface_exists($className,false);
00318: }
00319: return true;
00320: }
Curiously, in the initial project, I can run [font="Courier New"]yiic[/font] but not the [font="Courier New"]model User[/font] command. I get pretty much the same error message, but as a prompt message
J:\Developpement\serveur\web>yiic shell test\index.php
Yii Interactive Tool v1.0 (based on Yii v1.0.7)
Please type 'help' for help. Type 'exit' to quit.
>> model User
Warning: include(PDO.php): failed to open stream: No such file or directory in J:\Developpement\serveur\yii\framework\YiiBase.php on line 316
Warning: include(): Failed opening 'PDO.php' for inclusion (include_path='.;C:\php5\pear;J:\Developpement\serveur\web\test\protected\models;
J:\Developpement\serveur\web\test\protected\components') in J:\Developpement\serveur\yii\framework\YiiBase.php on line 316
Fatal error: Class 'PDO' not found in J:\Developpement\serveur\yii\framework\db\CDbConnection.php on line 282
J:\Developpement\serveur\web>
Search I’ve done returned nothing. Does anybody could help me?
Kind regards,
Bruno.
pestaa
(Pestaa)
July 21, 2009, 11:18am
2
Accidentally aren’t you using Yii 1.1 unstable version with unit testing enabled? I ran a quick search for PDO.php and only found it in PHPUnit.
If not, could you please submit call stack trace, so we can find out where the whole thing went wrong?
bruno
(bruno_)
July 21, 2009, 11:31am
3
I didn’t either find the file! Apparently, I use yii 1.0.7 as the prompt show it. I’ve tested the requirements as well, and it shows me 1.0.7.
This is the html document generated. You’ll find all informations about the error in it :
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>
PHP Error</title>
<style type="text/css">
/*<![CDATA[*/
body {font-family:"Verdana";font-weight:normal;color:black;background-color:whit
e;}
h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
h3 {font-family:"Verdana";font-weight:bold;font-size:11pt}
p {font-family:"Verdana";font-size:9pt;}
pre {font-family:"Lucida Console";font-size:10pt;}
.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;}
.message {color: maroon;}
.source {font-family:"Lucida Console";font-weight:normal;background-color:#ffffe
e;}
.error {background-color: #ffeeee;}
/*]]>*/
</style>
</head>
<body>
<h1>PHP Error</h1>
<h3>Description</h3>
<p class="message">
include(PDO.php): failed to open stream: No such file or directory</p>
<h3>Source File</h3>
<p>
J:\Developpement\serveur\yii\framework\YiiBase.php(316)</p>
<div class="source">
<pre>
00304: * @param string class name
00305: * @return boolean whether the class has been loaded successfully
00306: */
00307: public static function autoload($className)
00308: {
00309: // use include so that the error PHP file may appear
00310: if(isset(self::$_coreClasses[$className]))
00311: include(YII_PATH.self::$_coreClasses[$className]);
00312: else if(isset(self::$_classes[$className]))
00313: include(self::$_classes[$className]);
00314: else
00315: {
<div class="error">00316: include($className.'.php');
</div>00317: return class_exists($className,false) || interface_exis
ts($className,false);
00318: }
00319: return true;
00320: }
00321:
00322: /**
00323: * Writes a trace message.
00324: * This method will only log a message when the application is in deb
ug mode.
00325: * @param string message to be logged
00326: * @param string category of the message
00327: * @see log
00328: */
</pre>
</div><!-- end of source -->
<h3>Stack Trace</h3>
<div class="callstack">
<pre>
#0 J:\Developpement\serveur\yii\framework\YiiBase.php(316): autoload()
#1 unknown(0): autoload()
#2 J:\Developpement\serveur\yii\framework\db\CDbConnection.php(282): spl_autoloa
d_call()
#3 J:\Developpement\serveur\yii\framework\db\CDbConnection.php(242): CDbConnecti
on->createPdoInstance()
#4 J:\Developpement\serveur\yii\framework\db\CDbConnection.php(223): CDbConnecti
on->open()
#5 J:\Developpement\serveur\yii\framework\db\CDbConnection.php(202): CDbConnecti
on->setActive()
#6 J:\Developpement\serveur\yii\framework\base\CModule.php(353): CDbConnection-&
gt;init()
#7 J:\Developpement\serveur\yii\framework\base\CApplication.php(338): CWebApplic
ation->getComponent()
#8 J:\Developpement\serveur\yii\framework\db\ar\CActiveRecord.php(839): CWebAppl
ication->getDb()
#9 J:\Developpement\serveur\yii\framework\db\ar\CActiveRecord.php(2153): Post-&g
t;getDbConnection()
#10 J:\Developpement\serveur\yii\framework\db\ar\CActiveRecord.php(635): CActive
RecordMetaData->__construct()
#11 J:\Developpement\serveur\web\blogyii\protected\models\Post.php(15): model()
#12 J:\Developpement\serveur\web\blogyii\protected\controllers\PostController.ph
p(157): model()
#13 J:\Developpement\serveur\yii\framework\web\actions\CInlineAction.php(32): Po
stController->actionList()
#14 J:\Developpement\serveur\yii\framework\web\CController.php(300): CInlineActi
on->run()
#15 J:\Developpement\serveur\yii\framework\web\filters\CFilterChain.php(129): Po
stController->runAction()
#16 J:\Developpement\serveur\yii\framework\web\filters\CFilter.php(41): CFilterC
hain->run()
#17 J:\Developpement\serveur\yii\framework\web\CController.php(952): CAccessCont
rolFilter->filter()
#18 J:\Developpement\serveur\yii\framework\web\filters\CInlineFilter.php(59): Po
stController->filterAccessControl()
#19 J:\Developpement\serveur\yii\framework\web\filters\CFilterChain.php(126): CI
nlineFilter->filter()
#20 J:\Developpement\serveur\yii\framework\web\CController.php(283): CFilterChai
n->run()
#21 J:\Developpement\serveur\yii\framework\web\CController.php(257): PostControl
ler->runActionWithFilters()
#22 J:\Developpement\serveur\yii\framework\web\CWebApplication.php(332): PostCon
troller->run()
#23 J:\Developpement\serveur\yii\framework\web\CWebApplication.php(120): CWebApp
lication->runController()
#24 J:\Developpement\serveur\yii\framework\base\CApplication.php(133): CWebAppli
cation->processRequest()
#25 J:\Developpement\serveur\web\blogyii\index.php(11): CWebApplication->run(
)
#26 J:\Developpement\serveur\yii\framework\cli\commands\ShellCommand.php(78): re
quire()
#27 J:\Developpement\serveur\yii\framework\console\CConsoleCommandRunner.php(62)
: ShellCommand->run()
#28 J:\Developpement\serveur\yii\framework\console\CConsoleApplication.php(88):
CConsoleCommandRunner->run()
#29 J:\Developpement\serveur\yii\framework\base\CApplication.php(133): CConsoleA
pplication->processRequest()
#30 J:\Developpement\serveur\yii\framework\yiic.php(31): CConsoleApplication->
;run()
#31 J:\Developpement\serveur\yii\framework\yiic(15): require_once()
</pre>
</div><!-- end of callstack -->
<div class="version">
2009-07-21 12:13:16 <a href="http://www.yiiframework.com/">Yii Framework</a>/1.0
.7</div>
</body>
</html>
Thanks for your help.
pestaa
(Pestaa)
July 21, 2009, 11:38am
4
Having a look at CDbConnection::createPdoInstance() gave me the feeling that you have misconfigured your db access details.
Make sure your database connection string in config.php contains ‘:’. If not, rewrite it while keeping conventions in front of your eyes:
SQLite: sqlite:/path/to/dbfile
MySQL: mysql:host=localhost;dbname=testdb
PostgreSQL: pgsql:host=localhost;port=5432;dbname=testdb
SQL Server: mssql:host=localhost;dbname=testdb
Oracle: oci:dbname=//localhost:1521/testdb
bruno
(bruno_)
July 21, 2009, 12:40pm
5
I’ve checked and it’s correct.
'connectionString'=>'mysql:host=localhost;dbname=blogyii',
I can access to the blog and create posts.
qiang
(Qiang Xue)
July 21, 2009, 1:38pm
6
The error means that you CLI php does not have PDO enabled. Check to make sure you CLI php is using the expected php.ini.
bruno
(bruno_)
July 21, 2009, 2:04pm
7
Thanks a lot to both of you. It was it… Again! I forgot EasyPHP uses a php.ini file placed in the apache folder. Sorry for this "double" thread.
edit : we can’t edit the title, it’s too bad. It’s useful for marking a thread as “solved”.
kareem_zok
(Kareemzok)
January 18, 2010, 12:00pm
8
Thanks a lot to both of you. It was it… Again! I forgot EasyPHP uses a php.ini file placed in the apache folder. Sorry for this "double" thread.
edit : we can’t edit the title, it’s too bad. It’s useful for marking a thread as “solved”.
i m using wamp server nd i got same problem any solution coz i didnt get it nd i m still new in yiiframeworks ,
PS: what is CLI ?
WTF
(Driverzip)
April 18, 2010, 10:10am
9
I had the same problem on my server. Recompile php with pdo support resolve the problem.
Regards,
Andrejs.
chrisb34
(Chrisb)
November 29, 2011, 7:32am
10
I’ve just spent hours trying to resolve this problem.
My development machine is a WAMP server, live server is nix based with PDO support enabled. I already run other Yii based sites so was particularly perplexed by this.
I had recently upgraded to Yii 1.1.8 and thought perhaps this was the problem…
No, as someone mentioned above, in the end it was down to a rogue php.ini file which I needed on the WAMP machine to increase the max execution time.
Phew !!!!