Category: YII

YII Command tool not working

Problem: YII Command tool was not working in the newly created YII application, While using the below command in the command prompt not getting any respond, but normally its work with other YII application. Every path has been configured correctly and not getting any errors. /var/www/yii-1.1.16/framework/yiic shell Screenshot: Solution: This caused due to access rules …

Continue reading

Permanent link to this article: https://blog.openshell.in/2015/03/yii-command-tool-not-working/

Use Number() instead of parseInt() in javascript

Recently I came across the issue in converting string to integer in Javascript(JS). I was used parseInt() method to convert string value into integer value. unfortunately, I was faced issue in chrome browser but all other browsers like firefox, ie and safari are worked fine. Its too hard time for me to find out the …

Continue reading

Permanent link to this article: https://blog.openshell.in/2014/01/use-number-instead-of-parseint-in-javascript/

Serailization & Unserialization in PHP

Serialization which help us to store or transport PHP data structure such as an array or object. All the storage meduim or database can store String type. It will generates a storable representation of a value. This is useful for storing or passing PHP values around without losing their type and structure. Essentially, it takes a …

Continue reading

Permanent link to this article: https://blog.openshell.in/2014/01/serailization-unserialization-in-php/

Dynamically create form in javascript on fly

To create a form dynamically using JavaScript on fly of the webpage. This which helps to create form and input controls dynamically. [javascript] /* To create form with javascript */ var form = document.createElement("form"); form.setAttribute(‘method’,"post"); // form method form.setAttribute(‘action’,"test.php"); // form action url form.setAttribute(‘name’,"frmName"); // form name form.setAttribute(‘id’,"frmId"); // form ID form.setAttribute(‘target’,"_blank"); // form target …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/12/dynamically-create-form-in-javascript-on-fly/

Stripe Payment Gateway Implementation

Stripe Payment Gateway Implementation: Steps to Implement: Download the stripe package(stripe). Extract that into the web accessible folder. Create an account in stripe using this url: https://manage.stripe.com/login After Created the account get the test secret key and test publishable key from your stripe account using this url: https://manage.stripe.com/account/apikeys Now in config.php file change the “testSecretKey” …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/10/stripe-payment-gateway-implementation/

YII Upload the file to FTP server

The below function used to upload the local file to remote directory. [php] /** * Upload the file in ftp directory * @param string $localFilePath * @param string $remoteFilePath . * @return boolean */ public function CopyFileToFtpBucketDir($localFilePath, $remoteFilePath) { <strong><em>//Credential are configured in main.php</em></strong> $ftpSource = Yii::app()-&gt;params[‘ftpSource’]; $ftpUserName = Yii::app()-&gt;params[‘ftpUserName’]; $ftpPassword = Yii::app()-&gt;params[‘ftpPassword’]; <em><strong>// set …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/10/yii-upload-the-file-to-ftp-server/

Find number of working days between two dates in Mysql

This which helps to find number of working days between two dates in Mysql. There is no specific or inbuilt function in mysql, For that we need to use the SQL query as below. [sql] SELECT 5 * ((DATEDIFF(@end_date, @start_date) ) DIV 7) + MID(‘0123455501234445012333450122234501101234000123450’, 7 * WEEKDAY(@start_date) + WEEKDAY(@end_date) + 1, 1) [/sql] For …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/08/find-number-of-working-days-between-two-dates-in-mysql/

YII – set default settings within module and controller

Which helps to overwrite default settings of module and controller. To set default controller, view, layout and theme. Set default controller within module [php] /** * @var string the default controller. */ public $defaultController = ‘controller_name’; [/php] To Set default layout, theme and views within controller, use the following commands. [php] /** * @var string …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/04/yii-set-default-settings-within-module-and-controller/

Installation of Yii

YII – Yes It Is YII is a high-performance PHP framework best for developing large-scale Web applications. Download the latest stable version from http://www.yiiframework.com/ Extract the folder and place it under the webroot location Eg., /var/www/ in linux and htdocs in windows php <path to yii folder>/framework/yiic.php webapp <applicationname> Additionally set the path for php in …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/03/installation-of-yii/

How to automate whodidit behaviour and timestamps in yii ActiveRecord model?

To automate whodidit and timestamps in yii activerecord model using beforesave() method. If the rule validation got success then only the beforesave() method will invoke. Without satisifying rule() in activerecord model, this method will not work. [php] protected function beforeSave() { if(parent::beforeSave()) { if($this->isNewRecord) { $this->created_on = time(); $this->created_by = (int)Yii::app()->user->id; } $this->updated_on = time(); …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/03/how-to-automate-whodidit-behaviour-and-timestamps-in-yii-activerecord-model/