This set of PHP Quiz focuses on “Working with Databases-2”.
1. Which one of the following statements should be used to include a file? 2. Which one of the following methods is responsible for sending the query to the database? 3. Which one of the following methods recuperates any memory consumed by a result set? 4. Which of the methods are used to manage result sets using both associative and indexed arrays? 5. Which one of the following method is used to retrieve the number of rows affected by an INSERT, UPDATE, or DELETE query? 6. Which version of MySQL introduced the prepared statements? 7. Which of the following methods is used to execute the statement after the parameters have been bound? 8. Which one of the following methods is used to recuperating prepared statements resources? 9. Which method retrieves each row from the prepared statement result and assigns the fields to the bound results? 10. Which method rolls back the present transaction? Sanfoundry Global Education & Learning Series – PHP Programming. To practice all areas of PHP for Quizzes, here is complete set of 1000+ Multiple Choice Questions and Answers on PHP.
a) #include ‘filename’;
b) include ‘filename’;
c) @include ‘filename’;
d) #include
View Answer
Explanation: An example of this-
<?php
#include 'mysql.connect.php';
//begin database selection and queries.
?>
a) query()
b) send_query()
c) sendquery()
d) query_send()
View Answer
Explanation: Its prototype looks like-
class mysqli
{
mixed query(string query [, int resultmode])
}
a) destroy()
b) remover()
c) alloc()
d) free()
View Answer
Explanation: Once this method is executed, the result set is no longer available.
a) get_array() and get_row()
b) get_array() and get_column()
c) fetch_array() and fetch_row()
d) fetch_array() and fetch_column()
View Answer
Explanation: Their prototype is as follows-
calss mysqli_result
{
mixed fetch_array ([int resulttype])
}
calss mysqli_result
{
mixed fetch_row()
}
a) num_rows()
b) affected_rows()
c) changed_rows()
d) new_rows()
View Answer
Explanation: The method 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 affected_rows().
a) MySQL 4.0
b) MySQL 4.1
c) MySQL 4.2
d) MySQL 4.3
View Answer
Explanation: 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.
a) bind_param()
b) bind_result()
c) bound_param()
d) bound_result()
View Answer
Explanation: 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.
a) end()
b) finish()
c) final()
d) close()
View Answer
Explanation: Once you’ve finished using a prepared statement, the resources it requires can be recuperated with the close() method.
a) get_row()
b) fetch_row()
c) fetch()
d) row()
View Answer
Explanation: Its prototype follows:
class mysqli
{
boolean fetch()
}
a) commit()
b) undo()
c) back()
d) rollback()
View Answer
Explanation: Its prototype follows:
class mysqli
{
boolean rollback()
}