OOP with PHP5 Manual

“OOP or Object Oriented Programming is a good programming practice to create manageable projects more easily. Procedural programming means writing code without objects. Procedural programming consists of codes with or without routines. OOP enlightens any language for better coding, for best performance and for writing very big projects without worrying a lot about managing them. OOP gives you facilities to create reusable objects that you or other developers can use in their projects without reinventing them again and again. OOP removes the hassles and difficulties of writing and managing big applications.”

If you are a novice PHP programmer or even working with PHP for a quite long time but you are not familiar with Object Oriented Programming then the book Object-Oriented Programming with PHP5 written by Hasin Hayder should be your bible for learning OOP. Continue reading →

Concat multiple rows!

Today I was wondering how can I concatenate multiple rows in a single row. Suppose, I need to get the email addresses of a user table. The “SELECT `email` FROM `usertable`;” will return something like this:

email1

email2

email3

But I needed:

email1, email2, email3

It is very easy to process and make same output using PHP. But I thought there must be a way in MySQL. After searching a while I got the solution. Its simple.

SELECT group_concat(`email`) from `usertable`;

Thats it. Now I got what I wanted :).

Best flash charting script!

Uses of  flash chart is getting popularity day by day. Many medium to big web applications may use flash chart. But small application may ignore it due to complexities of implemention of flash chart. Even some web developers may not familiar with flash to make flash chart.

To make it easy, there are several open source and free of cost flash charting scripts that can be imported in your application. One of them is the  Open Flash Chart. So far I have seen, it is the best flash charting script which is very easy to implement. Moreover it supports many languages like PHP (4 & 5),  .NET, Java, Perl, Python etc. It provides the library files and examples which will understand very easily.

So test it now, and import it in your next project and impress your client.

PHP_SELF is empty!

Last two days, I am playing or learning to play with nginx web server. I have heard some reputation about it and saw some performance chart in the web. I liked it for its, as claimed, extremely low memory footprint for one of my small VPS.

After reading some tutorial in Projanmo Forum, I am successfully configured nginx, with with fastcgi, php-fpm, mysql etc. When I visit the website, I found some problems. Some section were not working. Later I found, where I used $_SERVER[‘PHP_SELF’] were not not working. Later investigating the phpinfo(); I have seen that some global php variables are empty. I found nothing on net. Later alamgir bro, helped to sort out. In fact the whole tutorial is contributed by him.

Solving this issue is real easy. Just add the following the in your nginx php configuration section.

include        fastcgi_params

The changed codes may look like: [copied directly from his mail]

location ~ \.php$ {
root           /www;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;

include        fastcgi_params;  #newly added

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

……….

……….

hope this will save your time :-).

AJAX and PHP, upgrades your sense

Ajax-php bookThis book, AJAX and PHP::Building Responsive Web Application, is one of the best book I have as it discussed the technology not only in theoretically but also with all real life example. The real life examples of this book were very attractive as the authors have shown how to make Chat Client, Google like Suggest & Autocomplete, Form Validation, Drag & Drop, RSS Feeder, Grid, Ajax based Charting etc. The book did not always treat readers as experts. So discussed many elementary things of technologies (like Javascript, XML, DOM) involved in AJAX. Another great thing, some examples’ work flow are shown in Flowchart which will enhance readers’ experience. The most helpful thing is that all codes are very very well commented. So, if anyone having basic idea on these techs can read this book. Continue reading →