Skip to content

Instantly share code, notes, and snippets.

@Chavao
Created March 19, 2012 01:36
Show Gist options
  • Save Chavao/2089545 to your computer and use it in GitHub Desktop.
Save Chavao/2089545 to your computer and use it in GitHub Desktop.
Uma solução que achei para tentar conexão em algum momento de instabilidade, dando até 5 segundos para desafogar e conseguir a conexão.
<?php
$i = 0;
while ($i++ < 5 && !$connected)
{
$connected = ($this->_resource = mysql_connect($host, $user, $password, true));
if(!$connected) {
sleep(1);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment