InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How To Get Current Url In Yii? |
|
Answer» YII::app () ->request->getUrl () method is used to GET current url in Yii FRAMEWORK. Yii::app () ->request->getUrl () method is used to get current url in Yii framework. |
|
| 2. |
What Is Difference Between “render” And “render Partial” In Yii? |
|
Answer» Render FUNCTION is used to render a VIEW in YII with specified layout whereas render partial is used to render only view layout is not INCLUDED in view. RenderPartial is basically used when we have to update a portion of page via AJAX. Usage Render ('yourviewname'); RenderPartial ('yourviewpartial'); Render function is used to render a view in Yii with specified layout whereas render partial is used to render only view layout is not included in view. RenderPartial is basically used when we have to update a portion of page via AJAX. Usage Render ('yourviewname'); RenderPartial ('yourviewpartial'); |
|
| 3. |
What Is Active Record (ar) In Yii? |
|
Answer» Active Record provides an object-oriented INTERFACE for accessing and manipulating DATA stored in databases. An Active Record class is associated with a database table, an Active Record instance CORRESPONDS to a row of that table, and an ATTRIBUTE of an Active Record instance represents the value of a particular column in that row. Instead of writing raw SQL statements, you would access Active Record ATTRIBUTES and call Active Record methods to access and manipulate the data stored in database tables. Active Record provides an object-oriented interface for accessing and manipulating data stored in databases. An Active Record class is associated with a database table, an Active Record instance corresponds to a row of that table, and an attribute of an Active Record instance represents the value of a particular column in that row. Instead of writing raw SQL statements, you would access Active Record attributes and call Active Record methods to access and manipulate the data stored in database tables. |
|
| 4. |
What Is C Model Class In Yii2? |
|
Answer» Yii C MODEL is the base class that provides the common features NEEDED by data model objects. C Model defines the basic FRAMEWORK for data MODELS that need to be validated. All Models in Yii extends C Model class. Yii C Model is the base class that provides the common features needed by data model objects. C Model defines the basic framework for data models that need to be validated. All Models in Yii extends C Model class. |
|
| 5. |
Benefits Of Yii Over Other Frameworks? |
Answer»
|
|
| 6. |
What Are Components In Yii 2? |
|
Answer» Components are an independent set of CODE written to perform specific TASK in controllers.Yii applications are built UPON components which are objects written to a specification. A component is an instance of Component or its derived class. Using a component mainly involves accessing its PROPERTIES and raising/handling its events. The base class Component specifies how to define properties and events. Components are an independent set of code written to perform specific task in controllers.Yii applications are built upon components which are objects written to a specification. A component is an instance of Component or its derived class. Using a component mainly involves accessing its properties and raising/handling its events. The base class Component specifies how to define properties and events. |
|
| 7. |
What Are Formatted In Yii2? |
|
Answer» FORMATTER is Yii application COMPONENT that is used format view data in readable format for users. By default the formatter is implemented by Yiii18nFormatter which provides a set of methods to format data as date/time, numbers, currencies, and other commonly used formats. You can use the formatter LIKE the following, $formatter = Yii::$app->formatter; // output: January 1, 2014 echo $formatter->asDate('2014-01-01', 'long'); // output: 12.50% echo $formatter->asPercent(0.125, 2); // output: cebe@example.com echo $formatter->asEmail('cebe@example.com'); // output: Yes echo $formatter->asBoolean(true); // it also handles display of null VALUES: // output: (not set) echo $formatter->asDate(null); Formatter is Yii application component that is used format view data in readable format for users. By default the formatter is implemented by Yiii18nFormatter which provides a set of methods to format data as date/time, numbers, currencies, and other commonly used formats. You can use the formatter like the following, $formatter = Yii::$app->formatter; // output: January 1, 2014 echo $formatter->asDate('2014-01-01', 'long'); // output: 12.50% echo $formatter->asPercent(0.125, 2); // output: cebe@example.com echo $formatter->asEmail('cebe@example.com'); // output: Yes echo $formatter->asBoolean(true); // it also handles display of null values: // output: (not set) echo $formatter->asDate(null); |
|
| 8. |
What Are Yii Helpers? |
|
Answer» Helpers are static classes in Yii that simplify common coding tasks, such as string or array manipulations, HTML code GENERATION, and so on. In Yii all helpers are KEPT under yii helpers NAMESPACE. You use a HELPER class in Yii by directly calling one of its static methods, like the following: use yii helpers Html; echo Html::encode('TEST > test'); Helpers are static classes in Yii that simplify common coding tasks, such as string or array manipulations, HTML code generation, and so on. In Yii all helpers are kept under yii helpers namespace. You use a helper class in Yii by directly calling one of its static methods, like the following: use yii helpers Html; echo Html::encode('Test > test'); |
|
| 9. |
Explain Request Life Cycle In Yii 2 Framework? |
|
Answer» When handling a user request, YII 2.0 application will undergo the following stages: 1. Pre-initialize the application with Application::preinit ();
6 Raise an onBeginRequest event;
8. Raise an onEndRequest event; When handling a user request, Yii 2.0 application will undergo the following stages: 1. Pre-initialize the application with Application::preinit (); 6 Raise an onBeginRequest event; 8. Raise an onEndRequest event; |
|
| 10. |
Explain Naming Convention In Yii 2 Framework? |
|
Answer» Yii follows below naming conventions:
Yii follows below naming conventions: |
|
| 11. |
What Is Name Of First File The Loaded When Yii Framework Starts? |
|
Answer» Index.php is first FILE that is called Yii framework starts. In turn it will create a new OBJECT of new YiiwebApplication and start the application. require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); // load application configuration $CONFIG = require(__DIR__ . '/../config/web.php'); // instantiate and configure the application (new yiiwebApplication($config))->RUN(); Index.php is first file that is called Yii framework starts. In turn it will create a new object of new YiiwebApplication and start the application. require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); // load application configuration $config = require(__DIR__ . '/../config/web.php'); // instantiate and configure the application (new yiiwebApplication($config))->run(); |
|
| 12. |
What Is “gii” In Yii 2 And For What It Is Used? |
|
Answer» GII is module powerful module provided by Yii framework. It helps you create and generate FULLY customized forms, models, CRUD for database and more. You can enable Gii by configuring it in the modules property of the APPLICATION. Depending upon how you created your application, you may find the following code is already provided in the config/web.php CONFIGURATION file: $config = [ ... ]; if (YII ENV DEV) { $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class' => 'yii Module', ]; } Gii is module powerful module provided by Yii framework. It helps you create and generate fully customized forms, models, CRUD for database and more. You can enable Gii by configuring it in the modules property of the application. Depending upon how you created your application, you may find the following code is already provided in the config/web.php configuration file: $config = [ ... ]; if (YII ENV DEV) { $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class' => 'yii Module', ]; } |
|
| 13. |
Please List Basic Server Requirements To Install Yii 2 Framework? |
|
Answer» YII 2 REQUIRES PHP 5.4 or above with Mbstring EXTENSION and PCRE-support. Yii 2 requires PHP 5.4 or above with Mbstring extension and PCRE-support. |
|
| 14. |
List Some Database Related Functions In Yii 2 Framework? |
|
Answer» Below are LIST of some database related functions used in Yii 2 Framework find(): Creates an yii dbActive QueryInterface instance for query purpose. Usages: //Getting first record matching with condition $user = User::find()->where(['name' => 'Abc'])->one(); Find All(): Returns a list of active record models that match the specified primary key value(s) or a set of column values. Usages: // find the CUSTOMERS whose primary key value is 10 $customers = Customer::find All (10); // find customers whose age is 30 and whose status is active $customers = Customer::find All (['age' => 30, 'status' => 'active']); INSERT (): Inserts a row into the associated database table using the attribute values of this record. Usages: $customer = new Customer; $customer->name = $name; $customer->email = $email; $customer->insert(); Delete(): Deletes the table row corresponding to this active record. Usages: $models = Customer::find()->where('status = 3')->all(); foreach ($models as $model) { $model->delete(); } Delete All(): Deletes rows in the table using the provided conditions. Usages: Customer::delete All ('status = 3'); save() :SAVES the current record. Usages: $customer = new Customer; // or $customer = Customer::find One ($id); $customer->name = $name; $customer->email = $email; $customer->save(); Below are list of some database related functions used in Yii 2 Framework find(): Creates an yii dbActive QueryInterface instance for query purpose. Usages: //Getting first record matching with condition $user = User::find()->where(['name' => 'Abc'])->one(); Find All(): Returns a list of active record models that match the specified primary key value(s) or a set of column values. Usages: // find the customers whose primary key value is 10 $customers = Customer::find All (10); // find customers whose age is 30 and whose status is active $customers = Customer::find All (['age' => 30, 'status' => 'active']); Insert (): Inserts a row into the associated database table using the attribute values of this record. Usages: $customer = new Customer; $customer->name = $name; $customer->email = $email; $customer->insert(); Delete(): Deletes the table row corresponding to this active record. Usages: $models = Customer::find()->where('status = 3')->all(); foreach ($models as $model) { $model->delete(); } Delete All(): Deletes rows in the table using the provided conditions. Usages: Customer::delete All ('status = 3'); save() :Saves the current record. Usages: $customer = new Customer; // or $customer = Customer::find One ($id); $customer->name = $name; $customer->email = $email; $customer->save(); |
|
| 15. |
List Some Features Yii2 Framework? |
|
Answer» Features of Yii Framework:
Features of Yii Framework: |
|
| 16. |
Provide Steps To Install Yii 2 Framework? |
|
Answer» You can INSTALL Yii2 by running below COMMANDS via composer: Composer global REQUIRE "fxp/composer-asset-plugin:^1.3.1" Composer create-project --prefer-dist yiisoft/yii2-app-BASIC basic You can install Yii2 by running below commands via composer: Composer global require "fxp/composer-asset-plugin:^1.3.1" Composer create-project --prefer-dist yiisoft/yii2-app-basic basic |
|
| 17. |
What Is Latest Version Yii 2 Framework? |
|
Answer» The LATEST VERSION of YII 2 is 2.0.12, released on June 5, 2017. The latest version of Yii 2 is 2.0.12, released on June 5, 2017. |
|
| 18. |
Which Php Version Is Required To Install Yii 2.0? |
|
Answer» Yii 2.0 requires PHP 5.4.0 or above and RUNS BEST with the latest version of PHP 7 too. Yii 2.0 requires PHP 5.4.0 or above and runs best with the latest version of PHP 7 too. |
|
| 19. |
What Is Yii 2 ? Please Explain? |
|
Answer» Yii 2 is one of the most popular Web PROGRAMMING FRAMEWORK written in PHP language.It can be used for developing all kinds of Web applications from BLOGS to e-commerce websites and ERP’s. Yii implements the MVC (Model-View-Controller) architectural pattern. Yii 2 is one of the most popular Web programming framework written in PHP language.It can be used for developing all kinds of Web applications from blogs to e-commerce websites and ERP’s. Yii implements the MVC (Model-View-Controller) architectural pattern. |
|