mysql과 연동되는 php함수
- 최초 등록일
- 2008.06.19
- 최종 저작일
- 2008.06
- 9페이지/ MS 워드
- 가격 2,500원
소개글
mysql과 연동되는php함수를 예제와 함께 서술하였습니다.
그리고 각각 연동함수와 관련된 다른 함수도 적어놓았습니다.
목차
1. mysql_close
2. mysql_connect
3. mysql_create_db
4. mysql_data_seek
5. mysql_db_query
6. mysql_drop_db
7. mysql_errno
8. mysql_error
9. mysql_fetch_array
등..
본문내용
1. mysql_close
- MySQL과의 연결을 끊는다.
- 사용방법: int mysql_close(int [link_identifier]);
- 사용예:
$connection = mysql_connect(“localhost”, ”mysql”, ””); //mysql 서버에 연결
Mysql_select_db(“bbs”, $connection); //bbs DB에 연결
$result = mysql_query(“select id from $board”, $connetction);
$total = mysql_num_rows($result);
Echo $ total;
Mysql_close($connection); //연결된 mysql 서버를 끊는다.
관련함수: mysql_connect(), mysql_pconnect()
2. mysql_connect
- mysql 서버에 연결한다.
- 사용방법: mysql_connect(string [hostname [:port] [:/path/to/socket] ] ,
string [username] , string [password] );
//첫 번째 인자는 연결할 호스트 이름, 두 번째는 mysql 사용자 이름, 세 번째는 패스워드
사용예:
$connection = mysql_connect(‘localhost:3306’,’dumky’,’mypassword’);
//로컬 호스트에 포트번호 3306을 통해서 연결 시도
Mysql_select_db (‘bbs’ , $connection);
$query = “select max(id) from requests”
$res = mysql_query($query, $connection);
$err = mysql_error():
If ($err)
{
Echo “Ack, rhere was an error”;
}
$row = mysql_fetch_row($res);
Echo “For future reference, Your tracking number is: “.$row[0];
?> -관련함수: mysql_close(), mysql_pconnect()
3. mysql_create_db
- 새로운 데이터베이스를 생성.
- 사용방법: int mysql_create_db(string database name, int [link_identifier] );
//첫 번째 인자는 새롭게 생성될 데이터베이스, 두 번째는 이전 mysql서버 연결 ID
사용예:
참고 자료
없음