Posts

Featured Post

Make display inline radioButtonList on Yii Framework

Image
By Default Yii display radioButtonList not inline like this :
$form->radioButtonList($model, 'gender', array('M' => 'Male', 'F' => 'Female'))
Change Code like this
$form->radioButtonList($model, 'gender', array('M' => 'Male', 'F' => 'Female'), array( 'labelOptions' => array('style' => 'display:inline'), 'separator' => ' ')) And Voila ... ! Thank's

Cascade delete parent child relation on Yii

Hello All, Sometimes we want to delete parent table on parent child relation on Yii, First we must set relation, Parent Model :
public function relations() { return array( 'Childs' => array(self::HAS_MANY, 'ChildModel', 'parent_id'), ); } Child Model :
public function relations() { return array( 'Parent' => array(self::BELONGS_TO, 'ParentModel', 'parent_id'), ); } On delete parent, at function below (parent model) :
public function beforeDelete(){ foreach($this->Childs as $c) $c->delete() return parent::beforeDelete(); } That's all. Hope this post can help you.

Change Landing Page Yii Framework

In certain conditions, we want the first page of our application dodirectly into actual applications,but we want toexplain in detail the application.
Todo that wecan redirectthe applicationto a specific pageby changingmain.phpat thedirectoryconfig.

'defaultController'='controller/action',
Example :

return array( ...'defaultController'=>home/index, ... );

Thx

Export and import big data mysql with mysqldump

To export big data on mysql use this command:
# mysqldump -u [username] -p [databasename] | gzip > [filename.sql.gz]
To import big data on mysql
First you must extract compress file  [filename.sql.gz] to [filename.sql]

#mysql -u  [username] -p
mysql> use [databasename];
mysql> source path/to/[filename.sql];  If your data is too big, the import process can be used long time, wait until finished. If not you must try from Import process.

Thx.

Error running Development: Rails 3.x launcher script was found instead of Rails 4.x one.

When Upgrade from rails 3.2.x to rails 4.0.0, we found error like : Error running Development: Rails 3.x launcher script was found instead of Rails 4.x one. This is because new project structure of rails 4.0.0. To solve this you must copy 'bin' from you'r rails to you'r root project.