CRUD operations stand for Create, Read, Update, and Delete. These operations are fundamental for interacting with data in a web application. Below is a brief explanation and example for each operation.
The Create operation is used to add new data to the database.
The Read operation retrieves data from the database.
The Update operation modifies existing data in the database.
The Delete operation removes data from the database.
<?php
// Establish database connection
$conn = new mysqli('localhost', 'username', 'password', 'database');
// Create
$sql_create = "INSERT INTO users (name, email) VALUES ('John Doe', 'john@example.com')";
$conn->query($sql_create);
// Read
$result = $conn->query("SELECT * FROM users");
while ($row = $result->fetch_assoc()) {
echo $row['name'] . ' - ' . $row['email'] . '<br>';
}
// Update
$sql_update = "UPDATE users SET email='john.doe@example.com' WHERE name='John Doe'";
$conn->query($sql_update);
// Delete
$sql_delete = "DELETE FROM users WHERE name='John Doe'";
$conn->query($sql_delete);
?>
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?