Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Contoh Penggunaan PDO PGSQL
- * @author Pusat Ilmu Secara Detil
- * @version 1.0
- */
- try {
- // setup koneksi
- $dbh = new PDO("pgsql:host=localhost;dbname=mahasiswa", "root", "root",5432,array(
- PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- echo 'Gagal Koneksi.Pastikan string koneksi sesuai<br/>';
- }
- /*** Query Select ***/
- $sql = $dbh->prepare("SELECT * FROM mhs");
- $sql->execute();
- while($mhs = $sql->fetch())
- {
- print $mhs['nim'] .' - '. $mhs['nama'] .' - '.$mhs['alamat']. '<br />';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement