Category: PHP

In our PHP session you will learn about PHP, and how to execute scripts on your application

How to Reset a WordPress Password from Mysql Server

Its essential thing to knowing, how to reset the wordpress password from Mysql server without following traditional method. Because your site may hacked, you may forgot your admin password and its email id to reset the password, you are no longer able to login into wordpress using login credentials. This method will very useful to …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/09/how-to-reset-a-wordpress-password-from-mysql-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/

MySQL Error – SQL_BIG_SELECTS

While executing JOIN SQL query in live server, i got the following error. [code] The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay: [/code] To resolve this error, I have used the following SQL query before executing the JOIN SQL query. …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/08/mysql-error-sql_big_selects/

Mysql GROUP_CONCAT

MySQL has useful extention to the GROUP BY operation – function GROUP_CONCAT: GROUP_CONCAT(expr) – This function returns a string result with the concatenated non-NULL values from a group. Returns NULL when there are no non-NULL values. Where it can be useful? For example to get array without looping inside the code, In single SQL query …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/05/mysql-group_concat/

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/

How to automate timestamps in activerecord using yii

There are many ways to automate the setting of timestamps in yii ActiveRecord models. In this we are representing three ways here. 1) Update via model’s rules: [php] /** * @return array validation rules for model attributes. */ public function rules() { return array( array(‘title’,’length’,’max’=>255), array(‘title, created_at, updated_at’, ‘required’), array(‘updated_at’,’default’, ‘value’=>new CDbExpression(‘NOW()’), ‘setOnEmpty’=>false,’on’=>’update’), array(‘created_at,updated_at’,’default’, ‘value’=>new …

Continue reading

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

How to install pear php in ubuntu?

Installing pear php in ubuntu machine helps  you to use existing libraries to make our development easy. In terminal, run the following command: [code] sudo apt-get install php-pear [/code]

Permanent link to this article: https://blog.openshell.in/2013/02/how-to-install-pear-php-in-ubuntu/

Loop mysql result set multiple times or twice in php

First we will select something from the database and loop through it like so: [php] $result = mysql_query("SELECT * FROM my_table"); while($row = mysql_fetch_assoc($result)) { // inside the loop } [/php] Problem: if you want to loop through the same result set again, you will get an error because the internal pointer is currently at …

Continue reading

Permanent link to this article: https://blog.openshell.in/2013/01/loop-mysql-result-set-multiple-times-or-twice-in-php/