windows Zend 框架:未定义的类常量“MYSQL_ATTR_INIT_COMMAND”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2510267/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 14:11:02  来源:igfitidea点击:

Zend Framework: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND'

windowszend-framework

提问by Awan

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.

您可能已经知道,我从之前的问题中从 ubuntu 切换到了 Windows。我在 ubuntu 上开发 Zend Framework,现在在 Windows 上开发同一个项目。由于这种切换,我在 windows 中遇到了一些在 ubuntu 中没有发生的问题。

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

现在,当我进入登录页面时,firebug 控制台中出现以下错误:

<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

谢谢

采纳答案by Pascal MARTIN

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

这看起来与 PHP 的 bugtracker 上的这个 bug 有关:Bug #47224MYSQL_ATTR_INIT_COMMAND不再可用

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

似乎它已在 SVN 中修复——但可能不是在您使用的 PHP 版本中?


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.

[2009-07-02 06:43 UTC] mg at artigo dot pl
一个临时解决方案是使用 INT 值 ( 1002) 而不是常数。

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

这可能是一个临时解决方案,直到您安装新版本的 PHP,其中修复了错误?

回答by Sk8erPeter

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.inior sg. like this) in a text editor, and remove the semicolon from the following line:

我只是在 PHP 5.2.6 上遇到了同样的错误,我所要做的就是打开php.ini(例如在 Windows 上:C:\Windows\php.ini,或在 Ubuntu 上:/etc/php5/apache2/php.ini或sg。像这样)在文本编辑器中,并从以下行中删除分号

;extension=php_pdo_mysql.dll

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

因此,它在 php.ini 中看起来像这样:

extension=php_pdo_mysql.dll

That solved my problem.

那解决了我的问题。

回答by Charles

Looks like a Windows bug in PHP 5.3that 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.

看起来像PHP 5.3中的一个Windows 错误,它在不久前在 SVN 中得到了修复。您可能想尝试更新到最新的 PHP 版本以查看问题是否仍然存在。

回答by Sverre

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

我遇到了同样的错误,在 debian6 上,当我还没有安装时php-mysql,我只是安装了这个,就像这样

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.

我只是在这里添加它,以防其他人有同样的问题,为他们节省几分钟的研究时间。