【问题标题】:Lost Connection in query [duplicate]查询中失去连接[重复]
【发布时间】:2017-12-02 14:55:28
【问题描述】:
SELECT * FROM user_info LEFT JOiN general_information ON user_info.username = general_information.vendor_id LEFT JOIN company_information ON user_info.username = company_information.vendor_id LEFT JOIN usa_on_shore_site_locations ON user_info.username = usa_on_shore_site_locations.vendor_id LEFT JOIN core_competencies ON user_info.username = core_competencies.vendor_id LEFT JOIN industries_served ON user_info.username = industries_served.vendor_id LEFT JOIN vendor_level ON user_info.username = vendor_level.vendor_id LEFT JOIN nearshore_and_offshore_locations ON user_info.username = nearshore_and_offshore_locations.vendor_id LEFT JOIN languages ON user_info.username = languages.vendor_id LEFT JOIN services ON user_info.username = services.vendor_id LEFT JOIN remote_work_at_home_virtual_agents ON user_info.username = remote_work_at_home_virtual_agents.vendor_id LEFT JOIN remote_work_at_home_virtual_agents_countries ON user_info.username = remote_work_at_home_virtual_agents_countries.vendor_id LEFT JOIN technology ON user_info.username = technology.vendor_id LEFT JOIN certifications_compliance ON user_info.username = certifications_compliance.vendor_id LEFT JOIN business_mix ON user_info.username = business_mix.vendor_id WHERE general_information.street_address LIKE '%%' AND (languages.languages = 'Amharic' OR languages.all_languages = 'all' ) GROUP BY user_info.username

如何让我的查询在查询时不会丢失连接

【问题讨论】:

  • 您基本上是在问“我的连接掉线时怎么不会掉线?”您检查过 PHP 代码中的错误输出吗?

标签: php mysqli


【解决方案1】:

你必须使用mysql_ping()

根据PHP Documentation

检查与服务器的连接是否正常。如果 连接已断开并启用自动重新连接 重新连接。如果连接断开并且自动重新连接 禁用,mysql_ping() 返回错误。

您的解决方案:

$query = "SELECT * FROM user_info LEFT JOiN general_information ON user_info.username = general_information.vendor_id LEFT JOIN company_information ON user_info.username = company_information.vendor_id LEFT JOIN usa_on_shore_site_locations ON user_info.username = usa_on_shore_site_locations.vendor_id LEFT JOIN core_competencies ON user_info.username = core_competencies.vendor_id LEFT JOIN industries_served ON user_info.username = industries_served.vendor_id LEFT JOIN vendor_level ON user_info.username = vendor_level.vendor_id LEFT JOIN nearshore_and_offshore_locations ON user_info.username = nearshore_and_offshore_locations.vendor_id LEFT JOIN languages ON user_info.username = languages.vendor_id LEFT JOIN services ON user_info.username = services.vendor_id LEFT JOIN remote_work_at_home_virtual_agents ON user_info.username = remote_work_at_home_virtual_agents.vendor_id LEFT JOIN remote_work_at_home_virtual_agents_countries ON user_info.username = remote_work_at_home_virtual_agents_countries.vendor_id LEFT JOIN technology ON user_info.username = technology.vendor_id LEFT JOIN certifications_compliance ON user_info.username = certifications_compliance.vendor_id LEFT JOIN business_mix ON user_info.username = business_mix.vendor_id WHERE general_information.street_address LIKE '%%' AND (languages.languages = 'Amharic' OR languages.all_languages = 'all' ) GROUP BY user_info.username"
while(!mysql_ping($connection)) {
    sleep(5);
}
mysql_query($query) or die(mysql_error());

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-25
    • 2020-05-13
    • 2015-08-26
    • 1970-01-01
    • 2021-08-04
    • 2020-10-23
    • 2015-09-20
    • 2013-05-07
    相关资源
    最近更新 更多