Database Questions | PHP Questions

Que. Which one of the following methods recuperates any memory consumed by a result set?
a. alloc()
b. free()
c. destroy()
d. remover()

Answer: Option D


Que. What does the DESC keyword do in the following query?
SELECT *
FROM MY_TABLE
WHERE ID > 0
ORDER BY ID, NAME DESC"
a. It causes rows to be sorted by NAME first and then by ID
b. It causes rows with the same ID to be sorted by NAME in descending order
c. It causes rows with the same ID to be sorted by NAME in ascending order
d. It causes the dataset returned by the query to be sorted in descending order

Answer: It causes the result set to include a description of the NAME field


Que. The (|/) tells the server to match ___________
a. nothing
b. either nothing or a forward slash
c. forward slash
d. backward slash

Answer: Option D


Que. Which one of the following statements is used to create a table?
a. CREATE table_name (column_type column_name);
b. CREATE TABLE table_name (column_type column_name);
c. CREATE TABLE table_name (column_name column_type);
d. CREATE table_name (column_name column_type);

Answer: Option A


Que. Your confirmation form submits your choice, via the _______ method, to ________
a. GET admin.php
b. POST admin.php
c. GET index.php
d. POST index.php



Option D


Que. Which one of the following methods is responsible for sending the query to the database?
a. query_send()
b. sendquery()
c. query()
d. send_query()

Answer: Option A


Que. In which version of PHP was MySQL Native Driver(also known as mysqlnd) introduced?
a. PHP 5.3
b. PHP 5.0
c. PHP 5.2
d. PHP 5.1

Answer: Option D


Que. When you are building administrative links you’ll need to accept two arguments, which of the following are they?
a. URL of previous entry and previous page
b. The current page and previous page
c. The current page and URL of the entry you are working with
d. URL of previous entry and URL of the entry you are working with

Answer: Option D


Que. 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_result()
d. bound_param()

Answer: Option A


Que. Which one of the following lines need to be uncommented or added in the php.ini file so as to enable mysqli extension?
a. extension=mysqli.dl
b. extension=php_mysqli.dll
c. extension=mysql.dll
d. extension=php_mysqli.dl



Option A


Que. Which one of the following statements instantiates the mysqli class?
a. $mysqli = new mysqli()
b. mysqli->new.mysqli()
c. mysqli = new mysqli()
d. $mysqli->new.mysqli()

Answer: Option B


Que. You need to check whether ______ is set, to determine whether you’re editing an entry or creating a new one.
a. $_SET[‘admin’].
b. $_GET[‘url’].
c. $_SET[‘url’].
d. $_GET[‘admin’].

Answer: Option A


Que. Which one of the following method is used to retrieve the number of rows affected by an INSERT, UPDATE, or DELETE query?
a. affected_rows()
b. changed_rows()
c. new_rows()
d. num_rows()

Answer: Option B


Que. ([w-]+) will match ___________
a. one or more word characters
b. one or more word characters and/or hypens
c. one word characters
d. one or more word characters and hypens

Answer: Option C


Que. SQL is not case sensitive. SELECT is the same as select.
a. True
b. False
c. Option A
d. NA



NA


Que. Which one of the following databases has PHP supported almost since the beginning?
a. MySQL
b. Oracle Database
c. SQL+
d. SQL

Answer: Option D


Que. To identify entries marked for deletion, you check whether $_GET[‘page’] == ‘delete’ inside __________
a. admin.php
b. index.ini
c. .htaccess
d. index.php

Answer: Option C


Que. The URLs in the administrative links won’t mean anything to admin.php unless you modify _________
a. .htaccess
b. .adminaccess
c. .htmlaccess
d. .urlaccess

Answer: Option A


Que. Which one of the following methods can be used to diagnose and display information about a MySQL connection error?
a. connect_errno()
b. mysqli_connect_error()
c. mysqli_connect_errno()
d. connect_error()

Answer: Option C


Que. Transactions are used to treat sets of SQL statements atomically.
a. Option A
b. NA
c. True
d. False



NA


Que. In PHP in order to access MySQL database you will use:
a. sql_connect() function
b. mysql_connect() function
c. mysqlconnect() function
d. mysql-connect() function

Answer: Option C


Que. Once your application can generate administrative links, you need to load those links into _________
a. start.php
b. php.ini
c. index.ini
d. index.php

Answer: Option C


Que. Which one of the following statements should be used to include a file?
a. #include ;
b. @include ‘filename’;
c. #include ‘filename’;
d. include ‘filename’;

Answer: Option B


Que. Which method returns the error code generated from the execution of the last MySQL function?
a. errornumber()
b. errnumber()
c. errorno()
d. errno()

Answer: Option A


Que. Which one of the following methods is used to recuperating prepared statements resources?
a. final()
b. finish()
c. close()
d. end()



Option D


Que. Which of the following DBMSs do not have a native PHP extension?
a. MySQL
b. Microsoft SQL Server
c. PostgreSQL
d. IBM DB/2

Answer: None of the above


Que. Which one of the following statements can be used to select the database?
a. mysqli=select_db(‘databasename’);
b. mysqli->select_db(‘databasename’);
c. $mysqli=select_db(‘databasename’);
d. $mysqli->select_db(‘databasename’);

Answer: Option D


Que. The updated MySQL extension released with PHP 5 is typically referred to as.
a. mysql
b. MySQL
c. mysqly
d. mysqli

Answer: Option C


Que. Which of the methods are used to manage result sets using both associative and indexed arrays?
a. fetch_array() and fetch_row()
b. fetch_array() and fetch_column()
c. get_array() and get_column()
d. get_array() and get_row()

Answer: Option C


Que. Which version of MySQL introduced the prepared statements?
a. MySQL 4.2
b. MySQL 4.3
c. MySQL 4.1
d. MySQL 4.0



Option B


Que. Which of the following is not an SQL aggregate function?
a. MAX
b. MIN
c. SUM
d. AVG

Answer: CURRENT_DATE()


Que. When a user confirms that he wishes to delete an entry, that entry’s URL is passed to a function which removes the entry from the __________
a. index.php
b. database
c. admin.php
d. function.inc.php

Answer: Option C


Que. Which method rolls back the present transaction?
a. commit()
b. undo()
c. back()
d. rollback()

Answer: Option D


Que. If there is no error, then what will the error() method return?
a. Empty String
b. 0
c. FALSE
d. TRUE

Answer: Option C


Que. Which method retrieves each row from the prepared statement result and assigns the fields to the bound results?
a. fetch_row()
b. row()
c. fetch()
d. get_row()



Option C


What is the advantage of using PEAR DB functions?

Answer:1) Same code can be used for all your databases.

What is PEAR DB library?

Answer: PEAR DB is an advanced object oriented database library which provides full database abstraction, that is we can use the same code for all our databases. If we want our code to be as portable as possible PEAR DB provides the best mix of speed, power, portability.

Explain DB::connect().

Answer: DB::connect() is used to create a connection to the database by using a DSN (Data Source Name). This function returns a database object.br> Syntax:
$db = DB::connect(DSN [,options]);

State the PEAR DB function to get the system error message, if the database connectiob fails.

Answer: getMessage() method is invoked on database object to display the system error message if the database connection fails.

What is PEAR?

Answer: PEAR is short form for PHP Extension and Application Repository. PEAR is a framework and distribution system for reusable PHP components. PEAR is a community-driven project with the PEAR Group as the governing body.

How to release connection from database using PEAR DB?

Answer: Just call disconnect() method on database object to force PHP to disconnect from database.
Like $db->disconnect();

Write syntax of connect function for postgresql.

Answer:
//an example of connection string can be like

$connection_strjng = "host=localhost port=4251 dbname=cs user=john";

resource pg_connect(string $connection_string[,int $conect_type]);