I opena connection with sql database in the parent or main program as follws:
Expand|Select|Wrap|Line Numbers
- $dbh = DBI->connect("DBI:mysql:database=$database;host=$host", $user, $pass) || die "\nDB connection error!\n";
As one of the process will take more time to finish, I open a fork as follows. And I try to do some sql commands inside the child process as below:
Expand|Select|Wrap|Line Numbers
- $pid = fork();
- if( $pid == 0 ){
- $sth = $dbh->prepare("update $table SET STATUS=0 where CONFIGID=$id");
- $sth->execute();
- }
Expand|Select|Wrap|Line Numbers
- DBD::mysql::st execute failed: MySQL server has gone away at test.pl line 172.
Expand|Select|Wrap|Line Numbers
- $dbh->{'mysql_auto_reconnect'} = 1;
Thanks and Regards