Develop

[php] php+db 연동(odbc, mssql, mysql, sybase)

by hooni posted Apr 23, 2013
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄
PHP에서 데이터베이스 연결 방식 1 - ODBC
$hostname = "localhost"; 
$username = "crabz_id"; 
$password = "crabz_pw"; 
$databasename = "crabz_db"; 

$connect = odbc_connect($hostname, $username, $password);
$query = "select * from crabz_table";
odbc_exec($connect,$query);


PHP에서 데이터베이스 연결 방식 2 - MS-SQL
$hostname = "localhost"; 
$username = "crabz_id"; 
$password = "crabz_pw"; 
$dbname = "crabz_db"; 

$connect = mssql_connect($hostname, $username, $password)
    or die ("Error Connect");
mssql_select_db($dbname, $connect) or die ("Error Database");

$sql="select * from crabz_table";

$result = mssql_query($sql, $connect); 
while($row = mssql_fetch_array($result)) {
    $row[crabz_title];
    $row[crabz_content];
}
mssql_close($connect);


PHP에서 데이터베이스 연결 방식 3 - MY-SQL
$hostname = "localhost"; 
$username = "crabz_id"; 
$password = "crabz_pw"; 
$dbname = "crabz_db"; 

$connect = mysql_connect($hostname, $username, $password)
     or die ("Error Connect");
mysql_select_db($dbname, $connect) or die ("Error Database");

$sql="select * from crabz_table";

$result = mysql_query($sql, $connect); 
while($row = mysql_fetch_array($result)) {
    $row[crabz_title];
    $row[crabz_content];
}
mysql_close($connect);


PHP에서 데이터베이스 연결 방식 4 - Sybase
$hostname = "localhost"; 
$username = "crabz_id"; 
$password = "crabz_pw"; 
$dbname = "crabz_db"; 

$connect = sybase_connect($hostname, $username, $password)
    or die ("Error Connect");
sybase_select_db($dbname, $connect) or die ("Error Database");

$sql="select * from crabz_table";

$result = sybase_query($sql, $connect); 
while($row = sybase_fetch_array($result)) {
    $row[crabz_title];
    $row[crabz_content];
}
sybase_close($connect);