Sunday, 9 June 2013

Install Yii framework in Ubuntu, Linux or Windows (php)

  • Setup Yii framework php project How to install php application using yii framework on ubuntu Linux windows simple step to install php yii application How to setup yii framework php
First download Yii framework from the site http://www.yiiframework.com/download/

Just follow the steps.


  • Unzip the zip file of Yii framework in to your local server's root and rename the folder as your wish. Lets consider name folder as 'yii'.
e.g. 
  • If you are installing Yii on Ubuntu or any Linux platform then unzip the zip file of Yii under 'var/www/' directory.
  • If you are installing Yii on Window machine using xampp then unzip the zip file of Yii under 'c:\xmapp\htdocs\' (considering xampp installation directory as 'c:\xampp')

  • For windows user, set path of php.exe environment variable. For that open 'Control Panel\System and Security\System' and click on 'Advanced system settings' then click on 'Environment variables' then under 'System variables' label find 'Path' variable, select it and click on edit button and set path of php.exe at then end after symbol ';'(e.g. If you are using xampp, then path is 'c:\xampp\php\php.exe;').

  • Now go to path where your framework directory is located like.
For Ubuntu or Linux users
Open terminal and type
cd /var/www/yii

For Windows users
Open command prompt and type
C:\>cd xampp\htdocs\yii

  • Now create new folder in your local server's root. Lets consider name folder as 'application_name'.

  • Run command to create application based on yii.
For ubuntu or Linux users:
yiic webapp /var/www/application_name

For windows users
yiic webapp C:\xampp\htdocs\application_name

  • Press enter after doing above things and it will ask for following
Create a Web application under '/var/www/application_name’? [Yes|No] y
or
Create a Web application under ‘E:\xampp\htdocs\application_name’? [Yes|No] y

  • Press Enter and all the necessary files will be created under
/var/www/application_name
or
C:\xampp\htdocs\application_name

  • At last you will get message
Your application has been created successfully.

  • URL to access this application is http://localhost/application_name/


If you have any problem, ask freely...!!!

Sunday, 21 April 2013

How to remove / hide index.php from url in yii framework (PHP)

  • remove index.php from url in yii hide index.php from url in yii php url styling php
Just follow steps:

  • Make sure that the hosting / your pc mod_rewrite module is active. if not actively try to activate in a way, open the httpd.conf file. You can check this in the phpinfo.php to find out.
Find line #LoadModule rewrite_module modules/mod_rewrite.so
and remove just '#'

  • Create file .htaccess under directory protected/ or protected/www/ where app's index.php file is hosted and add following code snippet
RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

  • Set main.php in your yii configuration, at component :
'urlManager' => array(
                'urlFormat'=>'path',
                'showScriptName'=>false,
                'caseSensitive'=>false,        
               ),

  • Now just hits the your app Url.

Database connection using JDBC ODBC Driver in JAVA

  • java database connection jdbc odbc how to connect java to database database connectivity simple code for java database connectivity

Code Snippet :


import java.sql.*;

class insertIntoTable

{
 public static void main(String args[]) {
       try {

           //load database driver
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
           
           //connect To database
          Connection c;
          c=DriverManager.getConnection("jdbc:odbc:RS");
          System.out.println("connect To database");  
  
           //create Statement
          Statement s;
          s=c.createStatement();
        
          //create String
         String x;
         x="INSERT into RS Values ('Shiva','Aiwale','Vita',21)";
   
          //execute query
         s.executeUpdate(x);
         System.out.println("Data Successfully Inserted");     
         c.close();
      }

      catch(Exception e) 
{
         System.out.println("Exception ="+e.getMessage());
      } 

  }

}

Saturday, 20 April 2013

Steps To Display Database Content to DataGridView in C#

  • .net asp .net how to use data grid view dynamic data in data grid view how to implement datagridview

1)  Establish connection to database :

SqlConnection conObj =  new SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=F:\WindowsFormsApplication5\WindowsFormsApplication5\StudentDatabase.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");

Note : 
  • SqlConnection Class found in "System.Data.SqlClient" Namespace, So that you need to specify ( using System.Data.SqlClient; ) namespace
         
2) Create string based on what data need to Display :

        String selectString="SELECT  * FROM employee";

3) Execute above string :


SqlDataAdapter    dataAdapterObj = new SqlDataAdapter(selectString, conObj);

Note : 
  • SqlDataAdapter constructor execute selectString and store result in dataAdapterObj
  • Require two input selectstring to execute and connection object (conObj)

4)Attach data from dataAdapterObject to DataTable object :

        DataAdapter dtObj=new DataAdapter();
                   dtObj.fill(dataAdapterObj );

5)Finally Attach data from data table (dtObj) to DataGridView using DataSource Property :

        datagridview1.DataSource=dtObj;

I hope you got it... If you have any query then ask me...


SAMPLE :





Saturday, 26 January 2013

Database Normalization and Types of Normalization

  • what is normalization and types of normalization 1NF 2NF 3NF with examples SQL simple definition of normalization

Normalization is the techinque of designing the database with the least redundancy and duplicacy of data. 


  • Types of Normalization:
    • First Normal Form
    • Second Normal Form
    • Third Normal Form
    • BCNF - Boyce Code Normal Form
    • Fifth Normal Form
    • Sixth Normal Form : Impossible to achieve this level of normalization
  • First Normal Form
    • Eliminate repeating groups in individual tables. 
    • Create a separate table for each set of related data. 
    • Identify each set of related data with a primary key.
    • Example :  
             Lets Consider Unnormalized table 




Tables should have only two dimensions. Since one student has several classes, these classes should be listed in a separate table. Fields Class1, Class2, and Class3 in the above records are indications of design trouble. 

 Spreadsheets often use the third dimension, but tables should not. Another way to look at this problem is with a one-to-many relationship, do not put the one side and the many side in the same table. Instead, create another table in first normal form by eliminating the repeating group (Class#), as shown below:


  • Second Normal Form
    • Create separate tables for sets of values that apply to multiple records. 
    • Relate these tables with a foreign key.
    • Example :
Note the multiple Class# values for each Student# value in the above table. Class# is not functionally dependent on Student# (primary key), so this relationship is not in second normal form.

The following two tables demonstrate second normal form:

                 Students :


                  Registration:


  • Third Normal Form
    • Eliminate fields that do not depend on the key.
    • Example :
In the last example, Adv-Room (the advisor's office number) is functionally dependent on the Advisor attribute. The solution is to move that attribute from the Students table to the Faculty table, as shown below:

                  Students :


                   Faculty :



Difference between DBMS and RDBMS

  • database management system vs relational database management system /
Database Management System VS Relational Database Management System

• Relationship among tables is maintained in a RDBMS whereas this not the case DBMS as it is used to manage the database.

• DBMS accepts the ‘flat file’ data that means there is no relation among different data whereas RDBMS does not accepts this type of design.

• DBMS is used for simpler business applications whereas RDBMS is used for more complex applications.

• Although the foreign key concept is supported by both DBMS and RDBMS but its only RDBMS that enforces the rules.

• RDBMS solution is required by large sets of data whereas small sets of data can be managed by DBMS.

Wednesday, 16 January 2013

How to know request is ajax or other in php


How to know whether the request is an ajax request or normal request in PHP? 

We can know it through following code:

$ajax false;

if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
 $ajax = true;
}
echo $ajax;

Wednesday, 2 January 2013

All Gmail Shortcuts

First enable shortcuts of gmail
for that go to setting and find Keyboard shortcuts and on it

Jumping
g then i : Go to Inbox
g then s : Go to Starred conversations
g then t : Go to Sent messages
g then d : Go to Drafts
g then a : Go to All mail
g then c : Go to Contacts
g then k : Go to Tasks
g then l : Go to Label

Threadlist selection
* then a : Select all conversations
* then n : Deselect all conversations
* then r : Select read conversations
* then u : Select unread conversations
* then s : Select starred conversations
* then t : Select unstarred conversations

Navigation
u : Back to threadlist
k / j : Newer/older conversation
o or <Enter> : Open conversation; collapse/expand conversation
p / n : Read previous/next message
` : Go to next inbox section
~ : Go to previous inbox section

Application
c : Compose
/ : Search mail
q : Search chat contacts
. : Open "more actions" menu
v : Open "move to" menu
l : Open "label as" menu
? : Open keyboard shortcut help

Actions
, : Move focus to toolbar
x : Select conversation
s : Rotate superstar
y : Remove label
e : Archive
m : Ignore conversation
! : Report as spam
# : Move to trash
r : Reply
<Shift> + r : Reply in a new window
a : Reply all
<Shift> + a : Reply all in a new window
f : Forward
<Shift> + f : Forward in a new window
<Shift> + n : Update conversation
<Tab> then Enter : Send mail
<Esc> : Focus last mole
] / [ : Remove conversation from current view and go previous/next
} / { : Archive conversation and go previous/next
z : Undo last action
<Shift> + i : Mark as read
<Shift> + u : Mark as unread
_ : Mark unread from the selected message
<Ctrl> + s : Save draft
+ or = : Mark as important
- : Mark as not important
g then p : Make a phone call
<Shift> + t : Add conversation to Tasks