Академический Документы
Профессиональный Документы
Культура Документы
A. TUJUAN
Setelah melaksankan praktikum ini diharapkan siswa dapat:
1. Membuat koneksi database MySQL menggunakan PDO
2. Membuat script PHP untuk operasi CRUD File Image dengan metoda penyimpanan File System
B. PENDAHULUAN
Page 1 of 9sync
Pros of Database:
1. ACID consistency which includes a rollback of an update that is complicated when the files are stored
outside the database.
2. Files will be in sync with the database so cannot be orphaned from it which gives you an upper hand in
tracking transactions.
3. Backups automatically include file binaries.
4. More Secure than saving in a File System.
Cons of Database:
1. You may have to convert the files to BLOB in order to store it in db.
2. Database Backups will become more hefty and heavy.
3. Memory ineffective. To add more, often RDBMS’s are RAM driven. So all data has to go to RAM first.
Yeah, that’s right. Had you ever thought about what happens when an RDBMS has to find and sort
data? RDBMS tracks each data page even lowest amount of data read/written, and it has to track if it’s
in memory or if it’s on disk if it’s indexed or sorted physically etc.
Filestream enables storing BLOB data in NTFS while at the same time it ensures transactional consistency
between the unstructured BLOB data with a structured data in database.
C. PRAKTIKUM
Pada praktikum PHP 04 ini, Anda akan membuat web aplikasi sederhana yang mengimplementasikan
operasi CRUD pada file image dengan metoda penyimpanan melalui File System. Berikut adalah layout web
yang akan dibuat:
Page 2 of 9sync
1. Create database dengan nama “db_fileupload”.
2. Create sebuah table dengan nama “gambar” dengan struktur seperti berikut:
3. Create sebuah sub directory dengan nama “simpan_image” pada directory htdocs.
4. Create 2 buah sub directory dengan nama “images” dan “upload” pada
../htdocs/simpan_image seperti pada gambar berikut:
5. Create sebuah file php dengan nama “connection.php” pada directory sub directory
“simpan_image”, yang berisi script untuk koneksi MySQL seperti berikut ini:
Page 3 of 9sync
6. Create sebuah file dengan nama “index.php”, dengan script sebagai berikut:
7. Create sebuah file dengan nama “add.php”, dengan script sebagai berikut:
Page 4 of 9sync
Page 5 of 9sync
8. Create sebuah file dengan nama edit.php, dengan script sebagai berikut:
Page 6 of 9sync
Page 7 of 9sync
sync
Page 8 of 9sync
9. Create sebuah file dengan nama delete.php, dengan script sebagai berikut:
D. LATIHAN SOAL
1. Jelaskan apa yang dimaksud dengan file binaries?
2. Jelaskan apa yang dimaksud dengan tipe data BLOB !
3. Jelaskan kegunaan dari fungsi extract() !, tuliskan contoh implementasinya !
4. Jelaskan kegunaan dari fungsi unlink() .
5. Jelaskan secara rinci apa yang dimaksud dengan $_FILES Array (HTTP File Upload variables) !.
6. Jelaskan kegunaan dari fungsi move_uploaded_file() .
E. KESIMPULAN
Page 9 of 9sync