查询中丢失的连接

时间:2017-06-29 03:56:23

标签: php mysqli

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

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

1 个答案:

答案 0 :(得分:1)

您必须使用mysql_ping()

按照PHP Documentation

  

检查与服务器的连接是否正常。如果   连接已关闭并启用自动重新连接尝试   重新连接。如果连接断开并且自动重新连接   disabled,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());