Category Archives: Yii Framework 2.0

Yii Framework 2 : Update Query

save() OR update() Update Multiple Records update() command Update By Sql Query You can use different type of methods to update the database records in yii2.0 framework. You can use model methods, execute() etc. save() OR update() Using model methods, You can load existing record and update the necessary changes in that. $model = User::find($id); […]

Yii Framework 2 : URL Manager

Each and every application will be accessed by URL. We can configure the URL format and can define the ‘RULES’ How to show and access the page via easy and pretty URL. Yii2.0 is having a flexibility to format the URL using urlManager components and we have to define it in web.php file under ‘config’ […]

Yii Framework 2 : Validation Rules for model attributes

After submitting the form data, We have to validate the input data information before we start to use. We can validate the inputs by calling the [[yii\base\Model::validate()]] method of yii2.0. Yii2.0 is giving the support for this data validation and also it is very easy way to test the input data. To check validate() of […]

What is Yii 2.0?

High performance is always a primary goal of Yii 1.x and Yii2.0. What is Yii? Best Of Yii Yii2.0 Features Yii2.0 Requirements What is Yii? Yii is a high performance, component-based PHP framework for rapidly developing modern Web applications. The name Yii can be considered as the acronym for Yes It Is!. Yii 2 inherits […]

Yii Framework 2 : Upsert Query

Upsert is an atomic operation. `Upsert()` will insert new record into a database table If table do not already exist or update them. upsert( $table, $insertColumns, $updateColumns = true, $params = []) Using QueryBuilder $sql = $queryBuilder->upsert(‘pages’, [ ‘name’ => ‘Home page’, ‘url’ => ‘https://bsourcecode.com/’, // url is unique ‘visits’ => 10000, ], [ ‘visits’ […]

Yii Framework 2 : ActiveForm Input Fields

Use the namespace For ActiveForm Active Form Begin And End Text Input Field TextArea Field Password Input Field HTML5 Email Input Field File Upload Checkbox Button Field Checkbox List Input Field Radio Button Field Radio Button List Field ListBox Field dropDown List Input Field Submit Button ‘yii\widgets\ActiveForm’ class is used to create a form and […]

Yii Framework 2 : Database Connection

Yii 2.0 DBMS Supports Yii 2.0 DBMS Configuration Yii 2.0 Multiple Database Connection Yii 2.0 How to use Multiple Database? Yii 2.0 Query with different DB connection Yii2.0 Database Connection To use the database we have to configure the database connection component by adding ‘db’ information to application config/main.php file. Yii 2.0 DBMS Supports Yii […]

Yii Framework 2 : DropDownList

“Do you know How to display the data in drop down list?” This tutorial will help you to display the array data or model data in drop down list in different way. Default DropDownList DropDownList With Prompt Text DropDownList With Model (DB) Data Default Selection DropDownList Default DropDownList Yii2.0 default dropdownlist syntaxt. <?php echo $form->field($model, […]

Yii Framework 2 : Scenarios

A model uses the yii\base\Model::$scenario property for the ‘Scenario’ concept. By default, a model supports only a single scenario named default. Yii2.0 framework model is designed in very comfortable way for dynamic logic based on scenario. In this tutorial i will share my experience about ‘Scenarios’. A model may be used in different scenarios in […]