March 24, 2010

Write Custom SQL in CakePHP

There may be a time when you want to simply just write your own custom sql in cakephp. Now, cakephp doesn’t want you to do this. The find() and save() calls should be able to do everything you need to do. But, I’ve found it useful to write custom sql queries for testing purposes. Here is how you do it.

$query = $this->ModelName->query("SELECT * FROM TableName");
  1. good explain.

    Comment by pankaj singh — September 6, 2010 @ 7:23 am

  2. good explain and helpful aritical

    Comment by kanij — August 7, 2011 @ 4:26 am

  3. very very good and helpful for me.in cack php

    Comment by kanij — August 7, 2011 @ 4:26 am

  4. thanx

    Comment by web developer — August 29, 2011 @ 6:32 am

  5. FAIL. USE CAKE!!!

    Comment by ryan — October 13, 2011 @ 9:06 am

Leave a comment