You are here: Re: INSERT into mysql alway make two entries « PHP Programming Language « IT news, forums, messages
Re: INSERT into mysql alway make two entries

Posted by Nils Bandener on 09/14/05 16:14

Sandman wrote:

> I recommend doing a persistent connection to MySQL outside this function. This
> way, you're making one new MySQL connection for every time the function is run.
> If this is the only function that ever use MySQL, it's no big deal, but if it
> isn't.
>
> Lookup mysql_pconnect

mysql_pconnect() could cause a couple of other problems, because it
keeps the connection open *after* the HTTP request has been finished.
See:

http://www.php.net/manual/en/features.persistent-connections.php

Better use the normal connect and cache the connection for re-use. For
example this way:

function makeDatabaseConnection()
{
static $link;

if (!isset($link))
{
$link = mysql_connect(...);
}
}

With subsequent mysql calls you don't even have to know the connection
because the mysql functions will automatically use the last established
connection.

Nils

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация