Yii is a high-performance, open-source PHP framework renowned for its efficiency and versatility in web application development. Launched in 2008, Yii (pronounced "yee") has gained a strong following among developers worldwide. It boasts a robust set of features, including a powerful extension system, seamless integration of third-party libraries, and comprehensive tools for handling security and scalability. With its emphasis on clean, maintainable code and rapid development, Yii is an excellent choice for building web applications of varying complexities, from simple websites to intricate enterprise solutions.
Show All Answers
Practice Test
71. What is the main advantage of using Yii's Active Record over traditional SQL queries?
A. Abstraction of database access details
B. Better performance
C. Simplified URL structure
D. Enhanced security features
Show Answer
Report This Question
Answer: Abstraction of database access details
72. What Yii method is used to create a new record in the database using Active Record?
A. 'save()'
B. 'insert()'
C. 'create()'
D. 'update()'
Show Answer
Report This Question
Answer: 'save()'
73. In Yii, how can you specify the fields to be inserted or updated when using Active Record?
A. Define attributes in the model class
B. Use the 'fields' parameter in 'save()' method
C. Set the 'tableFields' property
D. Modify the database schema
Show Answer
Report This Question
Answer: Define attributes in the model class
74. What is the purpose of the 'findByAttributes' method in Yii's Active Record?
A. Retrieve a record based on specified attributes
B. Delete records with matching attributes
C. Update records with matching attributes
D. Count the total number of records
Show Answer
Report This Question
Answer: Retrieve a record based on specified attributes
75. In Yii's Active Record, what method is used to retrieve a single record by its primary key?
A. 'findByPk()'
B. 'findOne()'
C. 'findByPrimary()'
D. 'getById()'
Show Answer
Report This Question
Answer: 'findByPk()'
76. What is the primary purpose of using 'scopes' in Yii's Active Record?
A. Defining reusable query conditions
B. Handling authentication
C. Managing database migrations
D. Implementing middleware
Show Answer
Report This Question
Answer: Defining reusable query conditions
77. In Yii, how can you perform a query that returns multiple records using Active Record?
A. 'findAll()'
B. 'findMany()'
C. 'getMany()'
D. 'query()'
Show Answer
Report This Question
Answer: 'findAll()'
78. What is the difference between 'findAll()' and 'find()' methods in Yii's Active Record?
A. 'findAll()' returns an array of all records, 'find()' returns a single record.
B. 'findAll()' supports pagination, 'find()' does not.
C. 'find()' returns an array of all records, 'findAll()' returns a single record.
D. 'find()' is used for creating records.
Show Answer
Report This Question
Answer: 'findAll()' returns an array of all records, 'find()' returns a single record.
79. In Yii's Active Record, what method is commonly used to delete a record from the database?
A. 'delete()'
B. 'remove()'
C. 'destroy()'
D. 'purge()'
Show Answer
Report This Question
Answer: 'delete()'
80. What is the primary purpose of RESTful routing in Yii?
A. Mapping URLs to controller actions
B. Creating database tables
C. Handling user authentication
D. Rendering view templates
Show Answer
Report This Question
Answer: Mapping URLs to controller actions