Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6595557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:57:19+00:00 2026-05-25T17:57:19+00:00

Have a find call on a table called Attachment which is assiciated with another

  • 0

Have a find call on a table called Attachment which is assiciated with another table called AddOn. I get a sql error. It seems to be looking for a field called display_field but this is not in the table. Why it is looking for it I do not know.

$previous = $this->AddOn->Attachment->find('first', array('conditions'=> array('model'=>'AddOn', 'foreign_key'=>$id)));

Error:

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 'display' at line 1 [CORE/cake/libs/model/datasources/dbo_source.php, line 684]

Query: display

Array
(
    [Attachment] => Array
        (
            [id] => 44
            [model] => AddOn
            [foreign_key] => 41
            [dirname] => img
            [basename] => fontgame_620x432.png
            [checksum] => 0488620c807cfaebb17489cb9c33f4fe
            [alternative] => Fontgame-620x432
            [group] => attachment
            [created] => 2011-09-22 14:04:35
            [modified] => 2011-09-22 14:04:35
            [file] => /home/t553788/public_html/res360/res/app/webroot/Media/transfer/img/fontgame_620x432.png
            [ratio] => 1.43518518519
            [known_ratio] => √2:1
            [megapixel] => 0
            [quality] => 1
            [width] => 620
            [height] => 432
            [bits] => 8
            [size] => 176726
            [mime_type] => image/png
        )

    [AddOn] => Array
        (
            [id] => 41
            [add_on_category_id] => 6
            [title] => new addon
            [description] => qwedwed
            [enabled] => 0
            [list_no] => 0
            [availability] => 1
            [price_quote_as] => 0
            [price] => 10.00
            [valid_from] => 2011-09-01
            [valid_to] => 2011-09-02
            [created] => 2011-09-20 18:22:51
            [updated] => 2011-09-22 16:29:38
            [deleted] => 0
            [display_field] => *missing*
        )

)

Attachment model:

        <?php
        class Attachment extends AppModel {

            var $name = 'Attachment';

            var $actsAs = array('Containable');

        }
        ?>

Addon Model;

            <?php
            class AddOn extends AppModel {

                var $name = 'AddOn';

                var $actsAs = array('Containable');

                var $belongsTo = array(

                    'AddOnCategory' => array('className' => 'AddOnCategory')

                );

                var $hasMany = array(

                    'AddOnPurchase' => array('className' => 'AddOnPurchase'),
                    'AddOnRateroom' => array('className' => 'AddOnRateroom'),

                    'Attachment' => array(
                          'className' => 'Media.Attachment',
                          'foreignKey' => 'foreign_key',
                          'conditions' => array('Attachment.model' => 'AddOn'),
                          'dependent' => true
                          )
                );

                /*
                var $validate = array(
                    'file' => array('mimeType' => array('rule' => array('checkMimeType', false, array( 'image/jpeg', 'image/png'))))
                );*/

                // before find  
                function beforeFind($queryData){

                    if(!isset($queryData['conditions']['AddOn.deleted'])){
                        $queryData['conditions']['AddOn.deleted'] = 0;
                    } 

                    return $queryData;

                }


            }
            ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:57:19+00:00Added an answer on May 25, 2026 at 5:57 pm

    The SQL query being performed is: display

    As you know, the SQL query you are looking for should start like: SELECT <something> FROM ...

    This one clearly doesn’t and that is what MySQL is trying to tell you.

    Check you aren’t calling a method called display() from any of your code:

    $this->display(); // in models or behaviors
    $this->Attachment->display(); // in controller, etc
    

    CakePHP tends to do this when you call a missing method on a model.

    A common culprit is thinking you have included a behavior by setting the model property $actAs when the correct property is actually called $actsAs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

do I have to call super in didTurnIntoFault ? I couldn't find any directions
I'm having some trouble with an SQL statement that have to find the number
Right now I have a table called Campaigns that has many Hits, if I
I'll just jump right into it. I have a model called Request which I
Let's say I have a table called my_table that looks like this: id |
I have a function that is called on document.ready that loops through a table
Imagine I have a table called item that has a column called price. In
I have a table called inbox_messages with following rows: user_id message_id ======= ========== 4
I have a table (posts) with a column called 'tag' I want to be
I need to get the last inserted id of table that have multi-column primary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.