- PHP에서 PostgreSQL 접속 테스트
1 소스 코드[ | ]
다음 내용을 test_pg.php 파일로 생성.
PHP
Copy
<?php
function xmp_print_r($arr) { echo '<xmp>'; print_r($arr); echo '</xmp>'; }
$conn = pg_connect('host=디비주소 port=포트 dbname=디비명 user=계정명 password=패스워드') or die('Could not connect: '.pg_last_error());
$res = pg_query("SELECT CURRENT_TIMESTAMP");
$arr = pg_fetch_all($res);
xmp_print_r($arr);
?>
2 실행예시[ | ]
브라우저에서 test_pg.php 접속
text
Copy
Array
(
[0] => Array
(
[now] => 2012-09-06 18:27:22.725361+09
)
)
3 같이 보기[ | ]
4 참고[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.