CakePHP – the right syntax to use near ‘generateList’


If you have been using the cakePHP 1.2 beta’s scarfold to bake (generate) your controller, when you go to the add article page, there will be an error message like the one below:

Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘generateList’ at line 1 [CORE/cake/libs/model/datasources/dbo_source.php, line 512]

If this happens to you, then that means your cake baked the wrong version of CRUD code for you, to fix the problem, you first locate the controller file, my controller’s name is posts, so my controller file is located at: cake/app/controllers/posts_controller.php.

Looking for the code:
generateList();

It may appear more than once in your code, replace it with:
find('list');

Since CakePHP 1.2, the CakePHP 1.1 syntax generateList(); has been replaced by the powerful find(”).

Hope this helps! :)

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Technorati
  • Twitter
  • Yahoo! Bookmarks

  1. #1 by Bill Goss on October 21, 2008 - 4:19 pm

    Incredible!

    I didn’t think that there was a solution I could find.

    How are you with zend eclipse?

    I can debug php scripts ok, but it chokes when I try to debug a controller with:
    class ‘controller’ not found

    If you don’t know the answer, I would sure appreciate a lead.

    Thanks again,

    Bill Goss

  2. #2 by admin on November 25, 2008 - 1:49 am

    Hi, Bill

    I am glad this post helps :)

    I am not so familiar with eclipse.

    cakephp has very bad error report, i also always receive: class ‘controller’ not found. The error message doesn’t make much sense, normally I will just have to dig into the cake or check the log for answer, hope this helps :)

  3. #3 by Fahad on November 28, 2008 - 5:31 am

    Thanks.
    Its really helpful

  4. #4 by nb on December 8, 2008 - 7:40 am

    thanks !

  5. #5 by pfwd on February 12, 2009 - 9:11 am

    thanks for this – really helpful

  6. #6 by Ghost on February 26, 2009 - 10:59 am

    One more…

    THANKS a lot!

  7. #7 by Sami Andoni on March 13, 2009 - 4:29 pm

    I need to say it, THANKS A LOT :)

  8. #8 by Pat M on March 20, 2009 - 4:27 am

    All at once now…

    THANK YOU!!!!!!!

    Your fix is the first in Google’s search for that SQL error.

  9. #9 by Navaneeth on May 6, 2009 - 4:09 am

    Great !!!!! , Thanks for sharing the solution. It saves lot of time. Thank u very much.

  10. #10 by shandercage on May 10, 2009 - 4:47 pm

    Thank you very much!!!!!!

  11. #11 by shandercage on May 10, 2009 - 4:48 pm

    replace generateList(), for find(’list’).
    Ole! Very easy!

  12. #12 by Kamal on September 5, 2009 - 11:55 am

    Thnx

(will not be published)