Hi!
I have a couple of small comments to Sinisa answer.
>>>>> "Sinisa" == Sinisa Milivojevic <[EMAIL PROTECTED]> writes:
Sinisa> Skriniar Gregor writes:
>> Dear all,
>>
>> I experienced some problems with using MySQL API:
>> My problem is that if I don't use database a long time it is disconnected and when
>I try to connect again at first I use method mysql_ping(), which reopens connection
>and that's the point. Please see next code of MySQL API:
>>
>> static my_bool mysql_reconnect(MYSQL *mysql)
>> {
>> MYSQL tmp_mysql;
>//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>local variable
>> DBUG_ENTER("mysql_reconnect");
>>
>> if (!mysql->reconnect ||
>> (mysql->server_status & SERVER_STATUS_IN_TRANS) || !mysql->host_info)
>> {
>> /* Allov reconnect next time */
mysql-> server_status&= ~SERVER_STATUS_IN_TRANS;
>> DBUG_RETURN(1);
>> }
>> mysql_init(&tmp_mysql);
>> tmp_mysql.options=mysql->options;
>> bzero((char*) &mysql->options,sizeof(mysql->options));
>> if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
mysql-> db, mysql->port, mysql->unix_socket,
mysql-> client_flag))
>> DBUG_RETURN(1);
>> tmp_mysql.free_me=mysql->free_me;
mysql-> free_me=0;
>> mysql_close(mysql);
>> *mysql=tmp_mysql;
>//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>the in/out param is pointed to local variable. What's a wilderness?!?
No, 'mysql' is not set to point to a local variable; We copy the
content (= the new connection) of the local variable to the in/out
parameter. This is perfectly ok and safe to do!
<cut>
Sinisa> I also do not see why should you use mysql_ping to reconnect.
It's actually quite ok to use mysql_ping() to reconnect...
Regards,
Monty
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php