Sunday, May 29, 2011

[PHP] What is the difference between sort & asort in php ?

Many times developers are not aware with the core functions of PHP. PHP have sort and asort built in array functions. You may or may not be aware with these functions. But when you will face a PHP interview than you may be asked for this question. What is the difference between sort & asort in php ? From the name itself, you can say it will sort an array elements but you may not be aware with the exact difference.sort() function will sort...

CakePHP PaginatorHelper-Sorting problem solved

Hello Friends,CakePHP provide its own Pagination helper using which you can easily add paging and sorting functionality in your CakePHP application. Using this helper class for one model, all instruction is given in below link. If you works with more than one model. means using belongsTo or hasMany relation and getting records from more than one table than paging is as simple...

How to use OR in find method – CakePHP

Hello Friends,When any developer is working with any web application, he/she will constantly interact with the Select Query. As i am working with CakePHP, i also need to use Select Query often. For Select Query in CakePHP, you can use find method of Model which gives you the data as per conditions given in find method. If you write more than one conditions in conditions array passed in find method than by default it will take OR clause and make a query string with “AND“. If you want to do OR operation...

Set Meta Tags (SEO Tags) in CakePHP

Hello Friends,In my previous post, i show you the way how to set Page Title Tag in CakePHP. But setting Meta keywords and Meta Description is not the same way as Meta Title. .Also Meta Keyword and Meta Description is important part of Search Engine Optimization. Refer to below syntax to set Meta tags in CakePHP.Set Meta Tags in CakePHP<?php echo $html->meta(‘keywords’,'enter any meta keyword here’); ?> //Output <meta name=”keywords” content=”enter any meta keyword here”/> <?php echo $html->meta(‘description’,'enter...

Set Meta Title (Page Title) in CakePHP 1.2/1.3

Hello Friends, As i mention in my previous posts, CakePHP 1.3 come up with lots of new syntax changes. I was looking for a Meta Title SEO tag for each page. I need to set this Meta Title (Page Title) for each page. You must be aware that Page Title can be set in method which we write in respective controller. Look at below syntax changes in CakePHP 1.2 and CakePHP 1.3 for setting Page Title. Page Title Syntax in...

Zip Component in CakePHP-Add files in Zip

Hello Friends,Today i have implemented a Zip functionality in CakePHP. If you want to create an archive file consists of some files to give a download Zip fileoption to user than i might help you to show the steps. Below are the steps how to zip all files and save it to some folder.Download Zip Component$this->Zip->addFile($src_file,$file_name_inzip);$this->Zip->saveZip(“myzipfile.zip”);First you can download the file given...

Problem in Mozilla Firefox-Easy AJAX Pagination Using JQuery CakePHP

Hello Friends,I was working with CakePHP’s Easy AJAX Pagination Using JQuery. I found this as a great code for sorting and paging with jQuery inCakePHP. But i faced a problem in Mozilla Firefox. It is not working in Mozilla Firefox. While in IE and Crome it works fine for me. For Mozilla Firefox when i debug it, it shows an error like “501 Method Not Implemented”. I searched for this error and Google gives the...

How to restrict users from accessing files & directory level(Protect directory) using .htaccess

Hello Friends,Today i faced a situation where i have to restrict or deny users from accessing files and folders of my web application directly by entering URL in browser which contain very important contents likeimages,pdfs,docs,etc. For this what i need to do is to protect the files and folders(directory) which contains images,pdfs and docs. We can restrict users from accessing files,folders and subfolders by using.htaccess(Hyper Text Files).Using .htaccess, you can restrict or deny access to individual...

301 Redirect old dynamic URLs to new static URLs using .htaccess

Hello Friends,Today i faced a situation where i need to redirect dynamic URL of my shopping cart to static url. I have changed the Dynamic URL(with query string , ? and &) to static one in my sunshop shopping cart. But still if i will open dynamic url with query string than it shows the content. This is a big issue with search engine as they will consider this dynamic page and static page as two different page and duplicate content issue araise.Redirect 301 rule in .htaccess (which is below) is common rule everybody knows.Using .htaccess redirect...