php - 正在准备语句,但未执行

标签 php mysql symfony doctrine-orm

我正在使用 FOSFacebookBundleFOSUserBundle使用 Symfony2 来管理我的用户。我在本地一切正常。但是,当我将所有内容推送到暂存环境时,我注意到用户在注册时并没有持久化(使用原则实体管理器)。

我检查的第一件事是我是否可以使用实体管理器保留其他内容,这很顺利。接下来我继续查看日志,发现有插入语句:

INSERT INTO user (username, username_canonical, email, email_canonical, enabled, salt, password, last_login, locked, expired, expires_at, confirmation_token, password_requested_at, roles, credentials_expired, credentials_expire_at, firstname, lastname, facebookID, date_of_birth, locale, gender, has_profile_pic, created_at, updated_at) 
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 
({"1":"1234","2":"1234","3":"foo@gmail.com","4":"foo@gmail.com","5":true,"6":"","7":"","8":null,"9":0,"10":false,"11":null,"12":null,"13":null,"14":["ROLE_FACEBOOK"],"15":0,"16":null,"17":"Mr","18":"Foo","19":"1234","20":{"date":"1986-12-09 00:00:00","timezone_type":3,"timezone":"PRC"},"21":"nl_NL","22":"male","23":1,"24":{"date":"2012-07-06 01:34:47","timezone_type":3,"timezone":"PRC"},"25":{"date":"2012-07-06 01:34:47","timezone_type":3,"timezone":"PRC"}})

当我用准备好的语句的值替换问号并手动发出查询时,一切正常。

有人知道这可能是什么吗?我也很高兴能得到有关如何进一步调试它的提示,因为我不知道下一步该去哪里..

提前致谢!

更新:

我又看了一眼 mysql 日志,我注意到正在准备 INSERT 语句,但从未执行过(与 select 语句不同)。我在错误日志中找不到任何错误。这是 mysql 日志:

34 Prepare SELECT t0.username AS username1, t0.username_canonical AS username_canonical2, t0.email AS email3, t0.email_canonical AS email_canonical4, t0.enabled AS enabled5, t0.salt AS salt6, t0.password AS password7, t0.last_login AS last_login8, t0.locked AS locked9, t0.expired AS expired10, t0.expires_at AS expires_at11, t0.confirmation_token AS confirmation_token12, t0.password_requested_at AS password_requested_at13, t0.roles AS roles14, t0.credentials_expired AS credentials_expired15, t0.credentials_expire_at AS credentials_expire_at16, t0.id AS id17, t0.firstname AS firstname18, t0.lastname AS lastname19, t0.facebookID AS facebookID20, t0.date_of_birth AS date_of_birth21, t0.locale AS locale22, t0.gender AS gender23, t0.has_profile_pic AS has_profile_pic24, t0.created_at AS created_at25, t0.updated_at AS updated_at26 FROM user t0 WHERE t0.facebookID = ?

34 Execute SELECT t0.username AS username1, t0.username_canonical AS username_canonical2, t0.email AS email3, t0.email_canonical AS email_canonical4, t0.enabled AS enabled5, t0.salt AS salt6, t0.password AS password7, t0.last_login AS last_login8, t0.locked AS locked9, t0.expired AS expired10, t0.expires_at AS expires_at11, t0.confirmation_token AS confirmation_token12, t0.password_requested_at AS password_requested_at13, t0.roles AS roles14, t0.credentials_expired AS credentials_expired15, t0.credentials_expire_at AS credentials_expire_at16, t0.id AS id17, t0.firstname AS firstname18, t0.lastname AS lastname19, t0.facebookID AS facebookID20, t0.date_of_birth AS date_of_birth21, t0.locale AS locale22, t0.gender AS gender23, t0.has_profile_pic AS has_profile_pic24, t0.created_at AS created_at25, t0.updated_at AS updated_at26 FROM user t0 WHERE t0.facebookID = '1234'
34 Close stmt  

34 Query START TRANSACTION
34 Prepare INSERT INTO user (username, username_canonical, email, email_canonical, enabled, salt, password, last_login, locked, expired, expires_at, confirmation_token, password_requested_at, roles, credentials_expired, credentials_expire_at, firstname, lastname, facebookID, date_of_birth, locale, gender, has_profile_pic, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
34 Close stmt  
34 Query COMMIT
34 Quit  

有什么线索吗?

更新 2:

我一直在 doctrine 库中记录 PDO 语句执行的一些返回值,事实证明我在我的开发环境中得到了一个正常的返回值 (1)。但是,我在生产环境中没有返回值。似乎是另一个提示,但我不知道该怎么做。

顺便说一句,PDOStatement::errorCode返回 00000(表示一切正常)

最佳答案

生产设置中 pdo_mysql 上的连接可能存在问题。检查一次。 根据comment给出答案.

关于php - 正在准备语句,但未执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11349748/

相关文章:

php - 过滤数据库值

php - 在 crontab 中运行 PHP 脚本仅在导出到文件时有效

mysql - TypeORM Querybuilder 获取嵌套 INNER JOIN

php - PHP 数组中的歧义

mysql - 将 MySQL 中的 DATETIME 值四舍五入到最近的分钟

java - Java 中的 ClassNotFoundException 和 mysql

postgresql - 使用 IS DISTINCT FROM 的 Symfony 原则

php - Symfony2 文件发现类不在其中

Symfony2 单元测试编译器通过

php - 在 PHP 中使用自动加载不好吗?