Databases Handling(Php ) Questions and Answers

Question 1. Which one of the following lines need to be uncommented or added in the php.ini file so as to enable mysqli extension?
  1.    extension=php_mysqli.dll
  2.    extension=mysql.dll
  3.    extension=php_mysqli.dl
  4.    extension=mysqli.dl
Explanation:-
Answer: Option A. -> extension=php_mysqli.dll
Also make sure that extension_dir directive points to the appropriate directory.

Question 2. In which version of PHP was MySQL Native Driver(also known as mysqlnd) introduced?
  1.    PHP 5.0
  2.    PHP 5.1
  3.    PHP 5.2
  4.    PHP 5.3
Explanation:-
Answer: Option D. -> PHP 5.3
PHP required that MySQL client library be installed on the server from which PHP was communicating with MySQL, whether the MySQL server also happened to reside locally or elsewhere. PHP 5.3 removes this problem by introducing MySQL Native Driver.

Question 3. Which one of the following databases has PHP supported almost since the beginning?
  1.    Oracle Database
  2.    SQL
  3.    SQL+
  4.    MySQL
Explanation:-
Answer: Option D. -> MySQL

Question 4. The updated MySQL extension released with PHP 5 is typically referred to as.
  1.    MySQL
  2.    mysql
  3.    mysqli
  4.    mysqly
Explanation:-
Answer: Option C. -> mysqli
The updated MySQL extension with PHP 5 is known as MySQL and typically referred to as mysqli.

Question 5. Which one of the following statements is used to create a table?
  1.    CREATE TABLE table_name (column_name column_type);
  2.    CREATE table_name (column_type column_name);
  3.    CREATE table_name (column_name column_type);
  4.    CREATE TABLE table_name (column_type column_name);
Explanation:-
Answer: Option A. -> CREATE TABLE table_name (column_name column_type);

Question 6. Which of the following methods is used to execute the statement after the parameters have been bound?
  1.    bind_param()
  2.    bind_result()
  3.    bound_param()
  4.    bound_result()
Explanation:-
Answer: Option A. -> bind_param()
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.

Question 7. Which version of MySQL introduced the prepared statements?
  1.    MySQL 4.0
  2.    MySQL 4.1
  3.    MySQL 4.2
  4.    MySQL 4.3
Explanation:-
Answer: Option B. -> MySQL 4.1
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.

Question 8. Which method rolls back the present transaction?
  1.    commit()
  2.    undo()
  3.    back()
  4.    rollback()
Explanation:-
Answer: Option D. -> rollback()
Its prototype follows:
class mysqli
{
boolean rollback()
}

Question 9. Which method retrieves each row from the prepared statement result and assigns the fields to the bound results?
  1.    get_row()
  2.    fetch_row()
  3.    fetch()
  4.    row()
Explanation:-
Answer: Option C. -> fetch()
Its prototype follows:
class mysqli
{
boolean fetch()
}

Question 10. Which one of the following methods is used to recuperating prepared statements resources?
  1.    end()
  2.    finish()
  3.    final()
  4.    close()
Explanation:-
Answer: Option D. -> close()
Once you’ve finished using a prepared statement, the resources it requires can be recuperated with the close() method.