Don't forget to hit the ⭐ if you like this repo.
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
.
-
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
-
Which PHP extension is commonly used to interact with MySQL databases?
- a) MySQLi
- b) PDO
- c) SQLi
- d) MySQLx
-
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
-
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()
- a)
-
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
-
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()
- a) Using
-
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
-
Which SQL statement is used to update data in a MySQL table?
- a) UPDATE
- b) INSERT
- c) SELECT
- d) DELETE
-
Which SQL statement is used to delete data from a MySQL table?
- a) DELETE
- b) INSERT
- c) UPDATE
- d) SELECT
-
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
-
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()
- a)
-
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()
- a) Using
-
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
-
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()
- a)
-
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()
- a) Using
-
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
- a)
-
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
-
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
-
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()
- a)
-
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
-
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()
- a)
-
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
-
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
-
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()
- a) Using
-
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()
- a)
-
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
-
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()
- a)
-
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
-
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
-
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
-
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()
- a)
-
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
-
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
-
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()
- a)
-
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
-
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()
- a)
-
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
-
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()
- a) By checking the return value of
-
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
-
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()
- a)
-
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
-
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()
- a) Using
-
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
-
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()
- a)
-
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
-
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()
- a) Using
-
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
-
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()
- a) Using
-
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
-
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()
- a)
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.