Skip to content

Latest commit

 

History

History
323 lines (265 loc) · 13.7 KB

n5bq.md

File metadata and controls

323 lines (265 loc) · 13.7 KB

Stars Badge Forks Badge Pull Requests Badge Issues Badge GitHub contributors Visitors

Don't forget to hit the ⭐ if you like this repo.

PHP: MySQL and CRUD

Set B

Please answer the following 50 multiple-choice questions to test your knowledge in MySQL and CRUD. You must place your answer file in the submission folder. Within the submission/Q5/set_b folder, create a folder called your github_id.

  1. What does CRUD stand for in the context of database operations?

    • a) Create, Read, Update, Delete
    • b) Copy, Rename, Update, Drop
    • c) Create, Remove, Upload, Delete
    • d) Control, Retrieve, Update, Destroy
  2. Which PHP extension is commonly used to interact with MySQL databases?

    • a) MySQLi
    • b) PDO
    • c) SQLi
    • d) MySQLx
  3. What is the purpose of the mysqli_connect() function in PHP?

    • a) To establish a connection to a MySQL database
    • b) To execute a SQL query
    • c) To fetch rows from a database result
    • d) To close a database connection
  4. Which PHP function is used to execute a SQL query in MySQL?

    • a) mysqli_query()
    • b) mysqli_fetch_assoc()
    • c) mysqli_connect()
    • d) mysqli_num_rows()
  5. What is the purpose of the mysqli_fetch_assoc() function in PHP?

    • a) To fetch a row from a database result as an associative array
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To get the number of rows in a database result
  6. How can you retrieve the number of rows returned by a SELECT query in MySQL using PHP?

    • a) Using mysqli_num_rows()
    • b) Using mysqli_query()
    • c) Using mysqli_fetch_assoc()
    • d) Using mysqli_connect()
  7. What is the purpose of the mysqli_insert_id() function in PHP?

    • a) To retrieve the ID generated by the previous INSERT query
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To get the number of rows affected by a query
  8. Which SQL statement is used to update data in a MySQL table?

    • a) UPDATE
    • b) INSERT
    • c) SELECT
    • d) DELETE
  9. Which SQL statement is used to delete data from a MySQL table?

    • a) DELETE
    • b) INSERT
    • c) UPDATE
    • d) SELECT
  10. What is the purpose of the mysqli_affected_rows() function in PHP?

    • a) To get the number of rows affected by a query
    • b) To execute a SQL query
    • c) To fetch a row from a database result as an associative array
    • d) To establish a connection to a MySQL database
  11. Which PHP function is used to escape special characters in a string to prevent SQL injection?

    • a) mysqli_real_escape_string()
    • b) mysqli_query()
    • c) mysqli_fetch_assoc()
    • d) mysqli_connect()
  12. How can you retrieve the error message associated with a MySQL query in PHP?

    • a) Using mysqli_error()
    • b) Using mysqli_query()
    • c) Using mysqli_fetch_assoc()
    • d) Using mysqli_connect()
  13. What is the purpose of the mysqli_close() function in PHP?

    • a) To close a database connection
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To fetch rows from a database result
  14. Which PHP function is used to check if a MySQL table exists?

    • a) mysqli_num_rows()
    • b) mysqli_query()
    • c) mysqli_fetch_assoc()
    • d) mysqli_table_exists()
  15. How can you retrieve the number of affected rows by an UPDATE or DELETE query in MySQL using PHP?

    • a) Using mysqli_affected_rows()
    • b) Using mysqli_num_rows()
    • c) Using mysqli_insert_id()
    • d) Using mysqli_error()
  16. Which PHP function is used to handle transactions in MySQL?

    • a) mysqli_begin_transaction()
    • b) mysqli_commit()
    • c) mysqli_rollback()
    • d) All of the above
  17. What is the purpose of the mysqli_commit() function in PHP?

    • a) To commit a transaction
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To fetch rows from a database result
  18. What is the purpose of the mysqli_rollback() function in PHP?

    • a) To rollback a transaction
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To fetch rows from a database result
  19. Which PHP function is used to get the last error message from a MySQL connection?

    • a) mysqli_error()
    • b) mysqli_errno()
    • c) mysqli_connect_error()
    • d) mysqli_connect_errno()
  20. What is the purpose of prepared statements in PHP when working with MySQL?

    • a) To prevent SQL injection and improve performance
    • b) To execute a SQL query
    • c) To fetch rows from a database result
    • d) To establish a connection to a MySQL database
  21. Which PHP function is used to bind parameters to a prepared statement in MySQL?

    • a) mysqli_stmt_bind_param()
    • b) mysqli_stmt_execute()
    • c) mysqli_stmt_get_result()
    • d) mysqli_stmt_fetch()
  22. What is the purpose of the mysqli_stmt_execute() function in PHP when working with prepared statements?

    • a) To execute a prepared statement
    • b) To bind parameters to a prepared statement
    • c) To get the result set of a prepared statement
    • d) To fetch rows from a prepared statement result
  23. What is the purpose of the mysqli_stmt_get_result() function in PHP when working with prepared statements?

    • a) To get the result set of a prepared statement
    • b) To execute a prepared statement
    • c) To bind parameters to a prepared statement
    • d) To fetch rows from a prepared statement result
  24. How can you retrieve the rows returned by a prepared statement in PHP when working with MySQL?

    • a) Using mysqli_stmt_get_result()
    • b) Using mysqli_stmt_fetch()
    • c) Using mysqli_stmt_execute()
    • d) Using mysqli_stmt_bind_param()
  25. Which PHP function is used to fetch a row from a prepared statement result in MySQL?

    • a) mysqli_stmt_fetch()
    • b) mysqli_stmt_get_result()
    • c) mysqli_stmt_execute()
    • d) mysqli_stmt_bind_param()
  26. What is the purpose of the mysqli_stmt_close() function in PHP?

    • a) To close a prepared statement
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To fetch rows from a database result
  27. Which PHP function is used to handle errors when working with MySQL in PHP?

    • a) mysqli_error()
    • b) mysqli_errno()
    • c) mysqli_connect_error()
    • d) mysqli_connect_errno()
  28. What is the purpose of the mysqli_fetch_row() function in PHP?

    • a) To fetch a row from a database result as an enumerated array
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To get the number of rows in a database result
  29. What is the purpose of the mysqli_fetch_array() function in PHP?

    • a) To fetch a row from a database result as an array (both associative and enumerated)
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To get the number of rows in a database result
  30. What is the purpose of the mysqli_fetch_object() function in PHP?

    • a) To fetch a row from a database result as an object
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To get the number of rows in a database result
  31. Which PHP function is used to retrieve the number of rows returned by a SELECT query in MySQL?

    • a) mysqli_num_rows()
    • b) mysqli_query()
    • c) mysqli_fetch_assoc()
    • d) mysqli_connect()
  32. What is the purpose of the mysqli_data_seek() function in PHP?

    • a) To move the internal result pointer to a specified row number
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To fetch rows from a database result
  33. What is the purpose of the mysqli_field_count() function in PHP?

    • a) To retrieve the number of fields in a result set
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To fetch rows from a database result
  34. Which PHP function is used to retrieve the metadata of a field in a result set in MySQL?

    • a) mysqli_fetch_field()
    • b) mysqli_field_count()
    • c) mysqli_num_rows()
    • d) mysqli_data_seek()
  35. What is the purpose of the mysqli_free_result() function in PHP?

    • a) To free the memory associated with a result set
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To fetch rows from a database result
  36. Which PHP function is used to retrieve the auto-generated ID of the last inserted row in MySQL?

    • a) mysqli_insert_id()
    • b) mysqli_num_rows()
    • c) mysqli_fetch_assoc()
    • d) mysqli_connect()
  37. What is the purpose of the mysqli_real_escape_string() function in PHP when working with MySQL?

    • a) To escape special characters in a string to prevent SQL injection
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To fetch rows from a database result
  38. How can you check if a MySQL query executed successfully in PHP?

    • a) By checking the return value of mysqli_query()
    • b) By checking the return value of mysqli_fetch_assoc()
    • c) By checking the return value of mysqli_connect()
    • d) By checking the return value of mysqli_num_rows()
  39. What is the purpose of the mysqli_num_rows() function in PHP?

    • a) To retrieve the number of rows in a result set
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To fetch rows from a database result
  40. Which PHP function is used to retrieve the current row of a result set in MySQL?

    • a) mysqli_fetch_row()
    • b) mysqli_fetch_array()
    • c) mysqli_fetch_object()
    • d) mysqli_fetch_assoc()
  41. What is the purpose of the mysqli_fetch_field() function in PHP when working with MySQL?

    • a) To retrieve the metadata of a field in a result set
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To fetch rows from a database result
  42. How can you retrieve the number of fields in a result set in PHP when working with MySQL?

    • a) Using mysqli_field_count()
    • b) Using mysqli_num_rows()
    • c) Using mysqli_data_seek()
    • d) Using mysqli_fetch_field()
  43. What is the purpose of the mysqli_fetch_all() function in PHP?

    • a) To fetch all rows from a result set as an array
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To get the number of rows in a result set
  44. Which PHP function is used to retrieve the current field value from a result set in MySQL?

    • a) mysqli_fetch_field()
    • b) mysqli_fetch_row()
    • c) mysqli_fetch_array()
    • d) mysqli_fetch_assoc()
  45. What is the purpose of the mysqli_store_result() function in PHP?

    • a) To store the entire result set from a query in memory
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To fetch rows from a database result
  46. How can you retrieve the number of affected rows by an INSERT, UPDATE, or DELETE query in PHP when working with MySQL?

    • a) Using mysqli_affected_rows()
    • b) Using mysqli_num_rows()
    • c) Using mysqli_fetch_assoc()
    • d) Using mysqli_num_fields()
  47. What is the purpose of the mysqli_multi_query() function in PHP?

    • a) To execute multiple SQL queries in a single call
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To fetch rows from a database result
  48. How can you retrieve the result of a multi-query execution in PHP when working with MySQL?

    • a) Using mysqli_use_result()
    • b) Using mysqli_store_result()
    • c) Using mysqli_next_result()
    • d) Using mysqli_free_result()
  49. What is the purpose of the mysqli_use_result() function in PHP when working with MySQL?

    • a) To retrieve the result set of a query incrementally
    • b) To execute a SQL query
    • c) To establish a connection to a MySQL database
    • d) To fetch rows from a database result
  50. Which PHP function is used to retrieve the next result from a multi-query execution in MySQL?

    • a) mysqli_next_result()
    • b) mysqli_use_result()
    • c) mysqli_store_result()
    • d) mysqli_free_result()

Contribution 🛠️

Please create an Issue for any improvements, suggestions or errors in the content.

You can also contact me using Linkedin for any other queries or feedback.

Visitors