Test Series - php

Test Number 27/39

Q: Which one of the following methods is responsible for sending the query to the database?
A. query()
B. send_query()
C. sendquery()
D. mysqli_query()
Solution: The method mysqli_query() is responsible for sending the query to the database. Query() method was previously used in older versions of PHP.
Q: Which one of the following methods recuperates any memory consumed by a result set?
A. destroy()
B. mysqli_free_result()
C. alloc()
D. free()
Solution: The function mysqli_free_result() is used to free the memory which is associated with the result. Once this method is executed, the result set is no longer available. Free() function was used in the previous version of PHP.
Q: Which of the methods are used to manage result sets using both associative and indexed arrays?
A. get_array() and get_row()
B. get_array() and get_column()
C. fetch_array() and fetch_row()
D. mysqli_fetch_array() and mysqli_fetch_row()
Solution: The method mysqli_fetch_array() is used to fetch a result row as an associative array or a numeric array.
And the function mysqli_fetch_row() is used to fetche one row from a result-set and returns it as an enumerated array.
The method fetch_array() and fetch_row() were used in the previous version of PHP.
Q: Which one of the following method is used to retrieve the number of rows affected by an INSERT, UPDATE, or DELETE query?
A. num_rows()
B. affected_rows()
C. changed_rows()
D. mysqli_affected_rows()
Solution: The method mysqli_num_rows() is only useful for determining the number of rows retrieved by a SELECT query. But to retrieve the number of rows affected by INSERT, UPDATE, or DELETE query, use mysqli_affected_rows(). Num_rows() and affected_rows() were used in previous version of PHP.
Q: Which version of MySQL introduced the prepared statements?
A. MySQL 4.0
B. MySQL 4.1
C. MySQL 4.2
D. MySQL 4.3
Solution: When the query() method is looped repeatedly it comes at a cost of both overhead, because of the need to repeatedly parsing of the almost identical query for validity, and coding convenience, because of the need to repeatedly reconfigure the query using the new values for each iteration. To help resolve the issues incurred by repeatedly executed queries, MySQL introduced prepared statements.
Q: Which of the following methods is used to execute the statement after the parameters have been bound?
A. bind_param()
B. bind_result()
C. bound_param()
D. bound_result()
Solution: Once the statement has been prepared, it needs to be executed. Exactly when it’s executed depends upon whether you want to work with bound parameters or bound results. In the case of bound parameters, you’d execute the statement after the parameters have been bound with the bind_param() method.
Q: Which one of the following methods is used to recuperating prepared statements resources?
A. end()
B. finish()
C. mysqli_close()
D. close()
Solution: The function mysqli_close() is used to close an opened database connection. Once you’ve finished using a prepared statement, the resources it requires can be recuperated with the mysqli_close() method. Close() was used in previous version of PHP.
Q: Which method retrieves each row from the prepared statement result and assigns the fields to the bound results?
A. get_row()
B. fetch_row()
C. fetch()
D. mysqli_fetch_row()
Solution: The function mysqli_fetch_row() is used to fetche row from a result-set and returns it as an enumerated array.
Its syntax is mysqli_fetch_row(result);
Q: Which method rolls back the present transaction?
A. commit()
B. undo()
C. mysqli_rollback()
D. rollback()
Solution: The function mysqli_rollback() is used to roll back from the current transaction for the specified database connection. Its syntax is: mysqli_rollback(connection);
Rollback() was used in previous version of PHP.

You Have Score    /9