Which of the following SQL clauses is used to filter the results of a query?
- SELECT
- FROM
- WHERE
- ORDER BY
The 'WHERE' clause in SQL is used to filter the results of a query. It allows you to specify conditions that must be met for a row to be included in the result set.
Which of the following is NOT a valid way to use a namespace in PHP?
- 'use' statement in a class
- Global namespaces
- Alias namespaces
- 'namespace' declaration within a class
In PHP, there are global namespaces, and using the 'use' statement in a class allows you to access classes from those namespaces. The global namespace does exist, so Option 2 is incorrect.
Which SQL statement is used to undo any changes made during the current transaction?
- ROLLBACK
- COMMIT
- SELECT
- DELETE
The ROLLBACK statement is used to undo any changes made during the current transaction. When a transaction encounters an issue or needs to be canceled for any reason, the ROLLBACK statement is issued to revert all the changes made during that transaction, ensuring data consistency and integrity. This is a fundamental part of the ACID (Atomicity, Consistency, Isolation, Durability) properties of database transactions.
In PHP, the option to prevent associative arrays from being converted into objects when encoding to JSON is ________.
- json_encode_assoc
- json_encode_object
- json_encode_array
- json_encode_options()
To prevent associative arrays from being converted into objects during JSON encoding in PHP, you can use the json_encode function with the JSON_FORCE_OBJECT option.
In PDO, which method is used to bind a value to a named placeholder in a prepared statement?
- bindParam()
- bindValue()
- execute()
- prepare()
The correct method in PDO to bind a value to a named placeholder is bindValue(). It allows for precise data binding and is commonly used in prepared statements.
Which PHP function is used to start a new session or to resume an existing session?
- session_start()
- start_session()
- begin_session()
- resume_session()
The session_start() function in PHP is used to start a new session or resume an existing session. It initializes session variables and allows you to work with user-specific data across multiple pages.
To get detailed information about an error that occurred in the last PDO operation, you would use the ________ method.
- errorInfo()
- getLast()
- debug()
- fetchError()
The 'errorInfo()' method in PDO provides detailed information about the last error that occurred during a PDO operation, aiding in debugging.
The function ________ in PHP is used to generate a random number.
- rand()
- random()
- mt_rand()
- generateRandomNumber()
In PHP, the rand() function is used to generate a random number. This function returns a pseudo-random integer within a specified range, making it useful for generating random values.
The ________ function in PHP can be used to regenerate a session ID.
- session_regenerate_cookie
- session_regenerate_id
- session_reset_id
- session_destroy
The correct option is session_regenerate_id. It regenerates the session ID and helps enhance session security.
When using PDO, which method is used to prepare a statement for execution?
- prepare()
- execute()
- query()
- bindParam()
The prepare() method in PDO is used to prepare an SQL statement for execution. It's typically used with placeholders to prevent SQL injection and to improve query performance by reusing the prepared statement with different parameter values.
Which of the following PHP functions is commonly used to create a hashed password?
- encrypt()
- hash_password()
- password_hash()
- create_hashed_password()
The password_hash() function in PHP is commonly used for creating hashed passwords. It incorporates strong encryption algorithms and automatically generates a unique salt for each password, enhancing security.
When a child class inherits from a parent class, it can also be referred to as a ________ relationship.
- Inheritance
- Association
- Aggregation
- Composition
In object-oriented programming, when a child class inherits from a parent class, it forms an inheritance relationship, inheriting properties and methods.