Ivan's Blog

Lets learn new things!

Install LAMP and phpMyAdmin in Ubuntu 12.04

sudo apt-get update sudo apt-get install apache2 sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt apt-cache search php5- sudo apt-get install name of the module sudo service apache2 restart sudo apt-get install phpmyadmin cd /etc/apache2/ sudo gedit apache2.conf Add this line at the end of this file: Include /etc/phpmyadmin/apache.conf sudo service apache2 restart Links: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-12-04 … Read More

[SQL]Some Common SQL Query

Create a temperature table with these columns id, temperature, time, date. SQL Query to find second highest temperature from the table: [code language=”sql”] select MAX(temperature) from temperature WHERE temperature NOT IN (select MAX(temperature) from temperature ); [/code] Another way: [code language=”sql”] SELECT `temperature` FROM `temperature` ORDER BY `temperature`.`temperature` DESC LIMIT 1,1 [/code] SQL Query to find maximum temperature of per … Read More

[SQL] Join

INNER JOIN gets all records from one table that have some related entry in a second table LEFT JOIN gets all records from the LEFT linked table but if you have selected some columns from the RIGHT table, if there is no related records, these columns will contain NULL RIGHT JOIN is like the above but gets all records in … Read More

How to use msgpack-java in eclipse

1. 1st install in Maven in windows Follow: this link http://www.mkyong.com/maven/how-to-install-maven-in-windows/ If “mvn –version” this command don’t work then run this “mvn -x –version” 2. Then download msgpack-java zip from this github https://github.com/msgpack/msgpack-java Unzip that folder. 3. Now go the downloaded folder of msgpack-java from command line(cmd) 4. Then follow these steps: https://github.com/msgpack/msgpack-java 5. After import the msgpack in Eclipse, … Read More

A brief discussion about most common object of Java: String, StringBuffer and StringBuilder

String, StringBuffer, StringBuilder are belongs to java core library : java.lang. All these three are implements of CharSequenceInterface. When creating a String object, it creating a string that can not be changed. So when its changing a new string object is creating. This is actually called string immutable(unchanging over time or unable to be changed). String’s or object’s toString() is … Read More

Yii 1.1: Some basic of theme

In a theme there is some basic folder structure: Here in blackboot theme, some basic folder, css, js, img, view->layouts In view->layouts, php files are design to get dynamic content from framework side and show them in particular sections(divs). Here, in $content variable, actual contents replaced for particular views. For other views like view->layouts->column1.php view->layouts->column2.php there used some other framework … Read More

Yii 1.1: Relations some example and links

In Model there is a function called relations. The array items are like that: [code language=”php”] ‘VarName’=&gt;array(‘RelationType’, ‘ClassName’, ‘ForeignKey’, …additional options) [/code] RelationType can be: BELONGS_TO HAS_MANY HAS_ONE MANY_MANY Example: [code language=”php”] <pre>array(         ‘posts’=&gt;array(self::HAS_MANY, ‘Post’, ‘author_id’),         ‘profile’=&gt;array(self::HAS_ONE, ‘Profile’, ‘owner_id’),      ); $post=Post::model()-&gt;findByPk(10); $author=$post-&gt;author; $posts=Post::model()-&gt;with(‘author’,’categories’)-&gt;findAll(); $posts=Post::model()-&gt;with(‘author.profile’,’author.posts’,’categories’)-&gt;findAll(); $posts=Post::model()-&gt;findAll(array(     ‘with’=&gt;array(         ‘author.profile’,         ‘author.posts’,         ‘categories’,     ) )); $users=User::model()-&gt;with(array( … Read More

Yii 1.1: Easy way to create a Module in Yii

Creating a module in Yii framework is very easy. Any one can see bellow link: http://www.yiiframework.com/doc/guide/1.1/en/basics.module Here I will describe how any one can create a module very easily in Yii. Yii have a code generator that is called gii. 1. If we have several database table, then 1st we need to generate model and CRUD from GII.     … Read More

Yii 1.1 : Use findAllBySql and NOT EXISTS query

Here i am showing use case of NOT EXISTS query and how to run raw query in yii. If any one want to display only those user name which are not in user role table, then have to run SQL query that with NOT EXISTS. In UserRole model write a function named: getUserNamesNotExists <?php public function getUserNamesNotExists() {     Yii::import(‘application.modules.user.*’); … Read More

Yii 1.1 : DropDown, Pagination, GridView, DetailsView

The most amazing this I noticed in Yii 1.1 framework is there build in module gii. By this module, anyone can generate a CRUD (Create, read, update and delete). Although it create most of the components like model, view, and controller but also we need to do some modification for better user experiences. Here I will discuss about those things: … Read More