Test your understanding of fundamental CRUD operations in PHP, including creating, reading, updating, and deleting data with simple examples.
Identifying the Insert Operation
Which function is used to add a new record into a MySQL database table using PHP and the mysqli extension?
- mysqli_create_table
- mysqli_read with ADD
- mysql_add with INSERT
- mysqli_store with ADD ROW
- mysqli_query with INSERT INTO
Reading Data from Database
What is the correct method to retrieve all records from a table named 'students' using PHP and mysqli?
- SELECT * FROM students
- GET * FROM students
- RETRIEVE ALL FROM students
- SHOW ALL FROM students
- EXPORT * FROM students
Updating a Record
Which SQL statement will correctly update the 'email' column for a user with id 10 in a PHP CRUD application?
- UPDATE users email TO 'new@example.com' WHERE id = 10
- SET email = 'new@example.com' IN users FOR id = 10
- UPDATE users SET email = 'new@example.com' WHERE id = 10
- CHANGE email IN users TO 'new@example.com' FOR id = 10
- MODIFY users SET email = 'new@example.com' AT id = 10
Deleting a Row Safely
What is the best practice to delete a row with a specific id from a 'products' table in PHP?
- ERASE FROM products WHEN id = 5
- DELETE * FROM products id = 5
- REMOVE FROM products SET id = 5
- DELETE products WHERE id = 5
- DELETE FROM products WHERE id = 5
Escaping User Input
Which PHP function should be used to safely escape user input when inserting data into a database to prevent SQL injection?
- escape_string_mysql
- mysqli_real_escape_string
- secure_input_filter
- htmlspecialchars
- mysql_input_escape