When limiting the number of results returned by a query in CodeIgniter, the ________ method is employed.

  • fetch()
  • get_limit()
  • limit()
  • restrict()
To limit the number of results returned by a query in CodeIgniter, the limit() method is used. It helps in specifying the number of records to be retrieved from the database result set.

What is the role of hooks in modifying the behavior of CodeIgniter controllers?

  • Hooks allow you to tap into the core system and execute custom code at specific points
  • Hooks are a way to create custom middleware for controllers
  • Hooks are only applicable in models, not controllers
  • Hooks are used to define URL patterns for routing
Hooks in CodeIgniter enable developers to modify the behavior of the core system at specific execution points. They provide a mechanism to extend or override the default functionality without directly modifying the core files.

In CodeIgniter, how are data passed from the controller to a view?

  • By directly accessing controller variables in the view
  • Through global variables
  • Using the $this->data() method
  • Via the $this->load->vars() method
Data is passed from a controller to a view in CodeIgniter using the $this->load->vars() method. This method allows you to set variables that can be accessed within the view. Directly accessing controller variables in the view is not considered a best practice.

What distinguishes a stored XSS attack from a reflected XSS attack?

  • Reflected XSS requires user interaction, while stored XSS does not.
  • Reflected XSS stores data on the server, while stored XSS reflects data to the user.
  • Stored XSS involves persistent injection of malicious scripts, while reflected XSS involves immediate execution without persistence.
  • Stored XSS occurs in client-side code, while reflected XSS occurs in server-side code.
Stored XSS refers to attacks where the injected script is permanently stored on the target server, affecting all users who view the compromised page. Reflected XSS, on the other hand, involves the immediate execution of the injected script without persistent storage.

In CodeIgniter, what is the purpose of the $db['default'] array found in the database configuration file?

  • It contains the default database query for all models
  • It defines the default database connection parameters
  • It is used to set the default database driver
  • It specifies the default database name for all controllers
The $db['default'] array in CodeIgniter's database configuration file is used to define the default database connection parameters.

________ is a common protocol used alongside OAuth for secure authorization.

  • HMAC (Hash-based Message Authentication Code)
  • JWT (JSON Web Token)
  • OpenID Connect
  • SAML
OpenID Connect is a common protocol used alongside OAuth for secure authorization. It provides a way to verify the identity of the user and obtain additional user information during authentication.

For complex queries, Active Record Class allows method ________ to directly write parts of the SQL query.

  • buildQuery()
  • composeQuery()
  • rawQuery()
  • writeQuery()
The correct method for directly writing parts of the SQL query in Active Record Class is rawQuery(). This method is useful for handling complex queries where direct SQL is required.

How does CodeIgniter handle database versioning through migrations?

  • A separate configuration file stores version numbers
  • CodeIgniter doesn't support database versioning
  • Each migration file includes a version number
  • The database server manages versioning automatically
CodeIgniter handles database versioning through migrations by including a version number in each migration file. This version number helps CodeIgniter keep track of which migrations have been executed and ensures the database schema is up-to-date with the application's code.

What is the primary purpose of database migrations in web development?

  • Data retrieval from the database
  • Dynamic content rendering
  • User authentication in CodeIgniter
  • Version control of the database schema
Database Migrations in CodeIgniter are primarily used for version control of the database schema. They allow developers to manage and apply changes to the database structure over time, ensuring a smooth transition between different versions of an application.

In CodeIgniter, where should the controller files be placed within the application structure?

  • /models
  • /views
  • /controllers
  • /core
CodeIgniter follows the MVC (Model-View-Controller) pattern, and controller files should be placed in the "/controllers" directory within the application structure. The other options are not the standard location for controllers.