Q
Which of the following PHP functions is used to get the number of rows affected by an SQL query in MySQLi extension?

Answer & Solution

Answer: Option B
Solution:
The mysqli_affected_rows() function in PHP MySQLi extension is used to get the number of rows affected by an SQL query such as INSERT, UPDATE, DELETE, or REPLACE. It returns the number of affected rows or -1 if the last query did not affect any rows.
Related Questions on Average

Which of the following SQL operations is used to remove all data from a database table?

A). INSERT

B). SELECT

C). TRUNCATE

D). DELETE

What is the primary purpose of the PDO::query() method in PHP PDO extension?

A). Establishing a database connection

B). Executing an SQL query

C). Fetching data from the database

D). Closing the database connection

What is the purpose of the mysqli_fetch_assoc() function in PHP?

A). Establishing a database connection

B). Executing SQL queries

C). Fetching data from the database

D). Closing the database connection

What is the purpose of the mysqli_close() function in PHP?

A). Establishing a database connection

B). Executing SQL queries

C). Fetching data from the database

D). Closing the database connection

Which of the following PHP functions is used to execute an SQL query in PDO extension?

A). pdo_execute()

B). pdo_query()

C). pdo_fetch()

D). pdo_prepare()

What is the primary advantage of using PDO extension over MySQLi for executing SQL queries in PHP?

A). Better performance

B). Improved security against SQL injection

C). Easier syntax

D). Compatibility with older PHP versions

What is the purpose of the mysqli_fetch_object() function in PHP?

A). Establishing a database connection

B). Executing SQL queries

C). Fetching data from the database

D). Closing the database connection

What is the primary advantage of using prepared statements in PHP for executing SQL queries?

A). Better performance

B). Improved security against SQL injection

C). Easier syntax

D). Compatibility with older PHP versions

Which PHP extension provides procedural and object-oriented approaches for executing SQL queries and interacting with MySQL databases?

A). PDO

B). MySQL

C). SQLI

D). MySQLi

What is the primary function of the mysqli_query() function in PHP?

A). Establishing a database connection

B). Executing SQL queries

C). Fetching data from the database

D). Closing the database connection