Sabtu, 31 Agustus 2013

PHP Indonesia - Facebook: apakah ada yg tau maksud code ini

PHP Indonesia - Facebook
PHP Indonesia is a community for everyone that loves PHP. Our focus is in the PHP world but our topics encompass the entire LAMP stack. Topics include PHP coding, to memcached handling, db optimizations, server stack, web server tuning, code deploying, hosting options and much much more. Youtube Channel : http://www.youtube.com/user/OurPHPIndonesia Twitter : @php_indonesia NOTE: Rules for Wall posting: https://www.facebook.com/groups/35688476100/doc/10151597056316101/ Daftar Keanggotaan : http://www.facebook.com/groups/35688476100/doc/10150671770741101/ 
Mobile Game Development Course

Learn how to create awesome HTML5 games that run on iPhone, iPad, Android and Desktop! Sign up today for this $99 online course.
From our sponsors
apakah ada yg tau maksud code ini
Aug 31st 2013, 14:11, by Noe Awalludin

Noe Awalludin 2:11pm Aug 31
apakah ada yg tau maksud code ini

<?php
require 'koneksi.php';
try {
$db = new PDO($dsn, $username, $password);
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sth = $db->query("SELECT * FROM locations");
$locations = $sth->fetchAll();
echo json_encode( $locations );
} catch (Exception $e) {
echo $e->getMessage();
}
?>

Ruli Armando 2:19pm Aug 31
ada

Faza Maula 2:22pm Aug 31
correct me if i'm wrong,
1. ambil data-data yang ada di file koneksi.php,
2. try - catch digunain untuk mengecek kesalahan sebelum hasil eksekusi ditampilkan.
3. buat objek baru dari class PDO, letakkan di variabel $db, 3 atribut didapetin dari file koneksi.php kyknya,
4. gunain fungsi setAttribute() yang di inherit dari class PDO
5. jalankan query pake variabel $sth
6. letakkan hasil query $sth di variabel $locations, fetch semua hasil query pake fungsi fetchAll() yang juga di inherit dari class PDO.
7. datanya berupa json, sehingga perlu di encode(atao kebalik yah) :v gak yakin..
8. catch exception, jika ada kesalahan saat memproses kode, letakkan di variabel $e, lalu tampilkan pesan kesalahan

*maaf sotoy*

Noe Awalludin 2:30pm Aug 31
tenkiu mastah Faza Maula

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions

Tidak ada komentar:

Posting Komentar