PHP & Others

[중요]mysql_connect 의 link identifier 다중생성

페이지 정보

본문

http://kr.php.net/manual/kr/function.mysql-connect.php

$a = mysql_connect('a', 'b', 'c');
$b = mysql_connect('a', 'b', 'c');
$c = mysql_connect('a', 'b', 'c');

위와 같은 예가 있을 때, $a만 생성되고 $b, $c 는 $a 를 가리키게 됩니다.

내가 짠 코드가 정상작동 하는줄 알았더니
connect 한번 더 하니까 오동작 하더군요.
원인이 php 의 친절한(?) 기능 덕분이라니-_-;

int mysql_connect ( [string server [, string username [, string password]]])
리퍼런스엔 여기까지만 나와있지만,
소스를 보니 더 있더군요.

$a = mysql_connect('a', 'b', 'c', 1);
$b = mysql_connect('a', 'b', 'c', 2);
$c = mysql_connect('a', 'b', 'c', 3);

이런식으로 하면 새로 생성됩니다. ㅠ_ㅠ 너무 다행.

----------------------------------------------------------------

http://kr.php.net/manual/en/function.mysql-connect.php
en 버전의 문서에는 친절하게 나와 있습니다.

$a = mysql_connect('a', 'b', 'c', true);
$b = mysql_connect('a', 'b', 'c', true);
$c = mysql_connect('a', 'b', 'c', true);

관련자료

등록된 댓글이 없습니다.
Today's proverb
우정은 사랑 받는 것 보다 사랑하는 것에 있다. (아리스토텔레스)