PHP Crud Pdo Insert Select Update Delete
Ringkasan
CRUD = Create, Read, Update, Delete. Polanya sama di semua engine berkat PDO.
Konsep Dasar
- Create:
INSERT+execute([...]). - Read:
SELECT+fetch/fetchAll. - Update:
UPDATE ... WHERE id=?. - Delete:
DELETE FROM ... WHERE id=?. - Ambil
lastInsertId()setelah insert.
Cara Kerja / Struktur
// Create
$st = $pdo->prepare("INSERT INTO posts(title, body) VALUES(?,?)");
$st->execute