Zend Framework: Undefined class constant 'MYSQ

2019-05-29 01:16发布

问题:

As you may have known that I switched from ubuntu to windows from my previous questions. I was working on Zend Framework on ubuntu and now working on same project in windows. Because of this switching I am facing some problems in windows which was not occurred in ubuntu.

Now I have the following error in firebug console when I go to login page:

<b>Fatal error</b>:  Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in <b>C:\wamp\www\vcred\library\Zend\Db\Adapter\Pdo\Mysql.php</b> on line <b>93</b><br />

Do you people know that what type of error is this and what is the solution?

I have the following configuration for database.

resources.db.adapter = "Pdo_Mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "test"
resources.db.params.charset = "utf8"

Thanks

回答1:

This looks related to this bug on PHP's bugtracker : Bug #47224 MYSQL_ATTR_INIT_COMMAND is no longer available

It seems it's been fixed in SVN -- but maybe not in the version of PHP you are using ?


Quoting one of the comments :

[2009-07-02 06:43 UTC] mg at artigo dot pl
A temporary solution is to use INT value (1002) instead of constant.

This might be a temporary solution, until you install a new version of PHP, in which the bug is fixed ?



回答2:

I just had the same error with PHP 5.2.6, and all I had to do is to open php.ini (e.g. on Windows: C:\Windows\php.ini, or on Ubuntu: /etc/php5/apache2/php.ini or sg. like this) in a text editor, and remove the semicolon from the following line:

;extension=php_pdo_mysql.dll

So as a result it would look like this in php.ini:

extension=php_pdo_mysql.dll

That solved my problem.



回答3:

Looks like a Windows bug in PHP 5.3 that was fixed in SVN a while ago. You might want to try updating to the latest PHP release to see if the issue still exists.



回答4:

I got the same error, on debian6, when I had not yet installed php-mysql so, I simply installed this, like this

apt-get install php5-mysql
/etc/init.d/apache2 restart

I just add it here, in case other have same problem, to save them them a few minutes of research.