1/56
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Where are Model files typically stored in a CodeIgniter application?
app/Models
app/Controllers
app/Views
app/Config
app/Models
Which method is used to delete a record from the database using a Model?
delete()
remove()
destroy()
erase()
delete()
How do you prevent direct access to view files via URL?
Use an .htaccess rule
Set permissions on the file
Rename the file to .view
Load the view using AJAX only
Use an .htaccess rule
Which function is used to load a view in CodeIgniter?
view()
load->view()
display_view()
show_view()
view()
How do you validate data before saving it in a Model?
Use the $validationRules property
validateData()
checkData()
validateBeforeSave()
Use the $validationRules property
What is the default return type of data when using Models in CodeIgniter?
Array
JSON
Object
XML
Array
Which method in a Model is used to retrieve a single row of data by its primary key?
find()
fetchRow()
retrieve()
getOne()
find()
What does the esc() function do in a view?
Escapes HTML characters to prevent XSS attacks
Exits the script
Includes a JavaScript file
Creates a new line in the HTML
Escapes HTML characters to prevent XSS attacks
What is the purpose of using layouts in CodeIgniter views?
To create a consistent structure across multiple pages
To load multiple models
To handle database connections
To route user requests
To create a consistent structure across multiple pages
Which of the following is true about views in CodeIgniter?
Views should only present data, not handle logic
Views should contain database queries
Views can directly manipulate session data
Views should handle form validation
Views should only present data, not handle logic
Which method can be used to get the number of affected rows from the last database operation?
affectedRows()
rowCount()
countRows()
getRowCount()
affectedRows()
Which method in a Model is used to update an existing record in the database?
update()
set()
modify()
change()
update()
Which of the following methods in CodeIgniter is used to pass data?
assign()
data()
$this->set()
with()
assign()
How can you specify a table in a Model to interact with?
protected $table property
setTable()
useTable()
table()
protected $table property
Which method is commonly used to retrieve all records from a database table using a Model?
findAll()
getAll()
retrieveAll()
get()
findAll()
Which method in a Model can be used to insert a new record into the database?
insert()
add()
saveData()
create()
insert()
What does the view() function return when loading a view?
A string containing the rendered view
Nothing
A boolean
An array
A string containing the rendered view
Where are the view files typically stored in a CodeIgniter application?
app/Views
app/Models
app/Controllers
App/Config
app/Views
Which method is used to render a view as a partial within another view?
view()
include()
render_partial()
embed_view()
view()
Which property should be defined in a Model to specify the primary key of the table?
protected $primaryKey
protected $id
protected $key
protected $identifier
protected $primaryKey
What does the save() method do in a Model?
Inserts or updates data based on whether the record exists
Only inserts data into the database
Only updates data in the database
Deletes a record if it exists
Inserts or updates data based on whether the record exists
What is the primary purpose of a View in CodeIgniter?
Present data to the user
Handle database queries
Manage application logic
Route HTTP requests
Present data to the user
What is the primary purpose of a Model in CodeIgniter?
Interact with the database
Configure routing
Handle user input
Manage views
Interact with the database
What is the purpose of the returnType property in a Model?
Specifies the format of returned data (e.g., array, object)
Defines the format for errors
Specifies the data type of the primary key
Configures the database connection
Specifies the format of returned data (e.g., array, object)
How can you access data passed from the controller in a view file?
As variables
Using $this->data
Using an array
Using objects
As variables
Which of the following functions can be used to include a CSS file in a view?
add_css('...')
load_css('...')
How can you pass multiple pieces of data to a view?
Using an associative array
Using JSON
Using multiple arguments
Using a string
Using an associative array
Which method is used to send data from a view back to the controller?
Data is not sent back; it's typically handled via forms
view->data()
transfer_data()
return_data()
Data is not sent back; it's typically handled via forms
It is a class file that can be associated with a URI.
Control
Function
Controller
Controller
The default controller can be set from which configuration file:
Database
Config
Routes
Autoload
Routes
T/F: Controllers are the heart of your application, as they determine how HTTP requests should be handled.
True
T/F: Views are called directly and must be loaded by a controller.
False
T/F:An example of storing view within sub-directories: $this->load->v('subdirectory_name/file_name');
False
T/F:The .php file extension does not need to be specified unless you use something other than .php.
True
T/F:The application/config/routes.php file determines which controller is called by default
False
T/F: This has an invalid class name:
True
To load a view file you will use the following method:
$this->load->data('name');
$this->load->file('name');
$this->load->view('name');
$this->load->view('name');
T/F: An example of storing view within sub-directories: $this->view('subdirectory_name/file_name');
False
T/F: CodeIgniter will handle multiple calls to $this->load->view() from within a controller.
True
T/F:Controller should extends the parent controller class so that it can inherit all its methods.
False
T/F: In an MVC framework, the Controller acts as the orchestrator, so it is responsible for fetching a particular view.
True
T/F: An example of storing view within subdirectories: $this->load->view("directory_name/file_name");
True
T/F: A view is simply a web page, or a page fragment (header, footer) and can be embedded within other views.
True
. _______ is an Application Development Framework - a toolkit - for people who build web sites using PHP.
Joomla
Zend
CodeIgniter
Wordpress
CodeIgniter
T/F: Class names must start with an uppercase letter.
True
List features of Codeigniter?
Model View Controller support System
Extremely Light Weight
Full Featured database classes with compatibility to several platforms
All of these
All of these
T/F: Views are called directly and must be loaded by a controller.
False
T/F: A Controller is a class file that can be associated with a URI.
True
T/F: CodeIgniter will intelligently handle multiple calls to $this->load->view() from within a controller.
True
T/F:Data is passed from the controller to the view by way of an array in the second parameter of the view loading method.
True
In the example: example.com/index.php/blog/, the , CodeIgniter would attempt to?
Create a class bolg
Find a controller named Blog.php
Call a function blog
Find a controller named Blog.php
T/F: If your URI contains more than two segments they will be passed to your method as function
False
T/F: CodeIgniter can load a default controller if only your site root URL is requested.
True
In this example: example.com/class/function/ID/foo/bar, what is the controller class?
example.com
class
Function
class
What is the file extension typically used for view files in CodeIgniter?
.php
.html
.xml
.view
.php
Which function is used to load a Model in CodeIgniter?
model()
get_model()
load->model()
use_model()
load->model()
GOODLUCK BTCHES :)