Sunday, February 14, 2010

All about Ajax and its states

Ajax (Asynchronous Javascript And XML) is used to update part of the webpage's content Asynchronously without reloading the entire page. Below are the five possible response states in Ajax
0: The request is uninitialized (before you've called open()).
1: The request is set up, but not sent (before you've called send()).
2: The request was sent and is in process (you can usually get content headers from the response at this point).
3: The request is in process; often some partial data is available from the response, but the server isn't finished with its response.
4: The response is complete; you can get the server's response and use it.

About ORM (Object Relation Mapping)

Accessing database using a layer of classes is called ORM. The rest of the application uses these classes and their objects. It never allow directly interacting with database.

1. ORM libraries map database tables to classes. If a database has a table users(plural).Our program will have a class named user(singular) stored in model folder,

2. Rows in this table correspond to objects of the class—a particular user is represented as an object of class user.
3. By using this object's attributes we can set and get the individual columns.

So an ORM layer maps tables to classes, rows to objects and columns to attributes of that object(methods).

Class methods are used to perform table-level operations.
Instance methods are used to perform operations on the individual rows.

It is all taken care by ActiveRecord class.

Zend installation steps

Zend framework requires php5 or later
1)Download the zend framework package from

2)Unzip the package and place it where ever you want
Here in my system /usr/var/zendframework

3)Open the zendframework/library and copy the folder path.

4)Open the php.ini file and set the include_path for this libray
Here in my system I have found include_path like include_path = ".:/usr/share/php5:/usr/share/pear , And i added the zend library path like include_path = ".:/usr/share/php5:/usr/share/pear:/var/www/ZendFramework/library"

5)Now we have create alias for (self executable file in console for linux) ,To do this run the fallowing command in terminal.
alias /var/www/ZendFramework/bin
6)Run the fallowing command in terminal
zf create project myproject
7)Now directory structure has been created with the name myproject.In this directory you will be given with some sub directories in order to develop your application(project).

PHP Design Patterns

Design pattern is nothing but how a civil engineer planed before start constructing any building i.e where a kitchen is, and how it will be, where temple room, where dining hall etc., In a software engineering design pattern is nothing but a blueprint for your software to avoid tight coupling of modules means when you modify some code in one module which doesn't take effect on other modules. The most usefull and common design patterns are

Sigleton pattern: Used to restrict instantiation of a class to one object only. The real time use of this pattern is connection to database is opened only once.

Factory pattern: Used to implement loosecoupled modules.

Observer pattern: Used to maintain all dependents and notifies them automatically when any change made