Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #7666 > unrolled thread
| Started by | cngrit <cngrit0305@gmail.com> |
|---|---|
| First post | 2012-11-30 06:15 -0800 |
| Last post | 2012-12-03 20:05 +0100 |
| Articles | 8 — 3 participants |
Back to article view | Back to comp.lang.php
must I close mysql_connect? cngrit <cngrit0305@gmail.com> - 2012-11-30 06:15 -0800
Re: must I close mysql_connect? Jerry Stuckle <jstucklex@attglobal.net> - 2012-11-30 09:34 -0500
Re: must I close mysql_connect? cngrit <cngrit0305@gmail.com> - 2012-11-30 23:43 -0800
Re: must I close mysql_connect? "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-12-03 10:30 +0100
Re: must I close mysql_connect? Jerry Stuckle <jstucklex@attglobal.net> - 2012-12-03 06:52 -0500
Re: must I close mysql_connect? "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-12-03 15:26 +0100
Re: must I close mysql_connect? Jerry Stuckle <jstucklex@attglobal.net> - 2012-12-03 11:09 -0500
Re: must I close mysql_connect? "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-12-03 20:05 +0100
| From | cngrit <cngrit0305@gmail.com> |
|---|---|
| Date | 2012-11-30 06:15 -0800 |
| Subject | must I close mysql_connect? |
| Message-ID | <38c11f96-5847-46f5-b4ab-6a9759dafaaf@googlegroups.com> |
In my script,I use mysql_connect to get a connection with mysql,now I want to know,after I used it ,I must to close it, or ignore it? if this connection will be used many times,i need to close it after the last time, or nothing to do? usually,which function you will use,mysql_connect or mysql_pconnect?
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-11-30 09:34 -0500 |
| Message-ID | <k9ag5c$v7g$1@dont-email.me> |
| In reply to | #7666 |
On 11/30/2012 9:15 AM, cngrit wrote: > In my script,I use mysql_connect to get a connection with mysql,now I want to know,after I used it ,I must to close it, or ignore it? > > if this connection will be used many times,i need to close it after the last time, or nothing to do? > > usually,which function you will use,mysql_connect or mysql_pconnect? > It's always good programming practice to clean up after yourself. This means closing connections when you're done with them. As for connecting - do you need a persistent connection? If so, why? If you can't provide good answers to those questions, you shouldn't be using mysql_pconnect(). -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | cngrit <cngrit0305@gmail.com> |
|---|---|
| Date | 2012-11-30 23:43 -0800 |
| Message-ID | <0bfda619-cf1a-49f6-90dd-b2bb932e9735@googlegroups.com> |
| In reply to | #7667 |
在 2012年11月30日星期五UTC+1下午3时34分15秒,Jerry Stuckle写道: > On 11/30/2012 9:15 AM, cngrit wrote: > In my script,I use mysql_connect to get a connection with mysql,now I want to know,after I used it ,I must to close it, or ignore it? > > if this connection will be used many times,i need to close it after the last time, or nothing to do? > > usually,which function you will use,mysql_connect or mysql_pconnect? > It's always good programming practice to clean up after yourself. This means closing connections when you're done with them. As for connecting - do you need a persistent connection? If so, why? If you can't provide good answers to those questions, you shouldn't be using mysql_pconnect(). -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== en,thank you very much,now,i know how to do.
[toc] | [prev] | [next] | [standalone]
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Date | 2012-12-03 10:30 +0100 |
| Message-ID | <ai39qjFt65oU2@mid.uni-berlin.de> |
| In reply to | #7666 |
Am 30.11.2012 15:15, schrieb cngrit: > In my script,I use mysql_connect to get a connection with mysql,now I want to know,after I used it ,I must to close it, or ignore it? > > if this connection will be used many times,i need to close it after the last time, or nothing to do? > > usually,which function you will use,mysql_connect or mysql_pconnect? > mysql_pconnect is broke, don't use it. mysql is obsolete, rather use mysqli, or even better, PDO. /Str.
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-12-03 06:52 -0500 |
| Message-ID | <k9i3q2$hag$1@dont-email.me> |
| In reply to | #7678 |
On 12/3/2012 4:30 AM, M. Strobel wrote: > Am 30.11.2012 15:15, schrieb cngrit: >> In my script,I use mysql_connect to get a connection with mysql,now I want to know,after I used it ,I must to close it, or ignore it? >> >> if this connection will be used many times,i need to close it after the last time, or nothing to do? >> >> usually,which function you will use,mysql_connect or mysql_pconnect? >> > mysql_pconnect is broke, don't use it. > > mysql is obsolete, rather use mysqli, or even better, PDO. > > /Str. > What's broke about mysql_pconnect() (other than the fact it has been deprecated)? (I'm not saying he should use it - I just want to know why you claim it's broken. Also, whether to use mysqli or pdo is a matter of choice - there are many reasons why someone might want mysqli. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Date | 2012-12-03 15:26 +0100 |
| Message-ID | <ai3r49F2nkcU1@mid.uni-berlin.de> |
| In reply to | #7679 |
Am 03.12.2012 12:52, schrieb Jerry Stuckle: > On 12/3/2012 4:30 AM, M. Strobel wrote: >> Am 30.11.2012 15:15, schrieb cngrit: >>> In my script,I use mysql_connect to get a connection with mysql,now I want to >>> know,after I used it ,I must to close it, or ignore it? >>> >>> if this connection will be used many times,i need to close it after the last time, >>> or nothing to do? >>> >>> usually,which function you will use,mysql_connect or mysql_pconnect? >>> >> mysql_pconnect is broke, don't use it. >> >> mysql is obsolete, rather use mysqli, or even better, PDO. >> >> /Str. >> > > What's broke about mysql_pconnect() (other than the fact it has been deprecated)? > (I'm not saying he should use it - I just want to know why you claim it's broken. I experienced this once myself with a system I started to administer, the old admin tried to optimize with pconnect, and it brought the web site to a halt. Then I read somewhere it was broke, and never used it again. The only reference I have is that a search for "mysql_pconnect issues" yields 24000 hits, and "mysqli_pconnect issues" 2400. Of course most links are quite old. Then I think the optimization achieved with pconnect is largely overestimated, and a risk if you use temp tables. Very often you can optimize your DB connection much more by using the local pipe instead of a local IP connection. > Also, whether to use mysqli or pdo is a matter of choice - there are many reasons why > someone might want mysqli. Sure, and you can base your choice on http://de2.php.net/manual/en/mysqlinfo.api.choosing.php , but in a newsgroup you get good advice, not only technical references. /Str.
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-12-03 11:09 -0500 |
| Message-ID | <k9iirc$egu$1@dont-email.me> |
| In reply to | #7681 |
On 12/3/2012 9:26 AM, M. Strobel wrote: > Am 03.12.2012 12:52, schrieb Jerry Stuckle: >> On 12/3/2012 4:30 AM, M. Strobel wrote: >>> Am 30.11.2012 15:15, schrieb cngrit: >>>> In my script,I use mysql_connect to get a connection with mysql,now I want to >>>> know,after I used it ,I must to close it, or ignore it? >>>> >>>> if this connection will be used many times,i need to close it after the last time, >>>> or nothing to do? >>>> >>>> usually,which function you will use,mysql_connect or mysql_pconnect? >>>> >>> mysql_pconnect is broke, don't use it. >>> >>> mysql is obsolete, rather use mysqli, or even better, PDO. >>> >>> /Str. >>> >> >> What's broke about mysql_pconnect() (other than the fact it has been deprecated)? >> (I'm not saying he should use it - I just want to know why you claim it's broken. > > I experienced this once myself with a system I started to administer, the old admin > tried to optimize with pconnect, and it brought the web site to a halt. Then I read > somewhere it was broke, and never used it again. The only reference I have is that a > search for "mysql_pconnect issues" yields 24000 hits, and "mysqli_pconnect issues" > 2400. Of course most links are quite old. > Just because the website came to a halt doesn't mean mysql_pconnect() is broken. There are a lot of things to consider when using persistent connections with *any* database - not the least being the system resources that are tied up even when there are no active connections to the database. Most people who try to use persistent connections have no idea what they are doing. It takes much more than just changing mysql_connect() to mysql_pconnect(). > Then I think the optimization achieved with pconnect is largely overestimated, and a > risk if you use temp tables. Very often you can optimize your DB connection much more > by using the local pipe instead of a local IP connection. > It can have advantages in heavily used systems (i.e. 100+ pages/sec. using the database). But you need to know what you're doing and how to tune the entire system. >> Also, whether to use mysqli or pdo is a matter of choice - there are many reasons why >> someone might want mysqli. > > Sure, and you can base your choice on > http://de2.php.net/manual/en/mysqlinfo.api.choosing.php , but in a newsgroup you get > good advice, not only technical references. > > /Str. > > Yes, and *your opinion* is to use PDO. You should say it is only your opinion. Others have different opinions. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Date | 2012-12-03 20:05 +0100 |
| Message-ID | <ai4bgaF6fj5U1@mid.uni-berlin.de> |
| In reply to | #7683 |
Am 03.12.2012 17:09, schrieb Jerry Stuckle: > On 12/3/2012 9:26 AM, M. Strobel wrote: >> Am 03.12.2012 12:52, schrieb Jerry Stuckle: --cut-- >>> Also, whether to use mysqli or pdo is a matter of choice - there are many reasons why >>> someone might want mysqli. >> >> Sure, and you can base your choice on >> http://de2.php.net/manual/en/mysqlinfo.api.choosing.php , but in a newsgroup you get >> good advice, not only technical references. >> >> /Str. >> >> > > Yes, and *your opinion* is to use PDO. You should say it is only your opinion. > Others have different opinions. <opinion> Every post to a newsgroup is either a hint, or an opinion. Every reader must find out himself what is useful information and what not, by relating the pronounced positions with his knowledge about the poster, the subject, and other sources of information. </opinion> I have had too many students copying from wikipedia wrong or just confusing sentences to give everybody this advice for every source of information. End of prayer. /Str.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web