Implementing MySql View in CakePHP For Typeahead Search

View works like a table, but it is not a table. It never exists; it is only a prepared SQL statement that is run when you reference the view name. A programmer can write VIEWs that limit the dataset both horizontally and vertically, ensuring that only the data that is required is queried for. Recently [...]

afterSave: A Great Callback Method for Soft Deleting Related Model Data( hasOne, hasMany, belongsTo)

Update: Here is model file to download Download Code I never like to “Hard Delete” data. Some one will make mistake deleting something. Then they will tell you retrive it. So “Soft Delete” can save you time telling you clients/boss why the data can not be retrieved. BTW “Soft Delete” means you keep a field [...]

Add Your Own Validation in model On CakePHP

Update: Here is model file to download Download Code CakePHP has many validation rules that can make model data validation much easier. There are 26 core validation rules. You can see here. These 26 rules almost covers all the validation. You can also add multiple validation to one field. But some time you need your [...]

Implementing Facebook Event API With fql.multiquery and With Graph Api

Facebook is our part of lifestyle and people are using this to create event so that friends can easily RSVP. Facebook Event is getting quite popular. Many Facebook application and website are using Facebook event api to show users events on their site and apps. Recently I added Facebook event functionality in http://apps.facebook.com/calendarised/. In this [...]

Should I Use Database For Storing sessions in CakePHP?

Session handling is a important part of any web app. CakePHP offers 4 storage facilities for session storage. I will go through all of them and discuss advantages and disadvantages of 3 of them. They are cake (Saves the session files in your app’s tmp/sessions directory.), database(Uses CakePHP’s database sessions), php(The default setting. Saves session [...]

Prevent Your CakePHP App From XSS Attacks

By default Cakephp will protect app against SQL Injection if you use CakePHP’s ORM methods (such as find() and save()) and proper array notation (ie. array(‘field’ => $value)) instead of raw SQL. But this does not potect you from XSS attacks. To Understand XSS attack, i will show a simple example. Create a php code [...]

CakePHP and facebook SDK as Vendor

For most of the application on Facebook is simple but sometimes you have such a big application to develop you need to use a php framework. As I am a CakePHP developer, I like to use CakePHP for these type of applications .In this How-To, I will show how you can add Facebook SDK in [...]

Disable Browser Cache in Cakephp

When developing web apps, sometimes it is better to disable browser cache. We can do it in php by following code So how do we set these in cakephp? Very simple This will produce headers like this I recommend calling this function in certain function rather than calling it beforeFilter() function in app_controller.php

How To Get The Pages The Facebook User is Admin Of

Some times you need the Facebook pages of a user. You can get it by simple fql. Here is how $user_pages will have the information about the pages that the user admin of. See this code in this post

Uploading a Video to Facebook User’s wall or Page’s wall

In this post I will show how you can post a image to user’s wall and to a page’s wall. To post image to page’s wall- the user logged must be admin of the page. Suppose Zakir is user of you admin. Now you want Zakir to post a image to a page (name of [...]