Saturday, July 25, 2015

Re: generateList() returning SQL error.

I found the error that was in the add.ctp. Changing $form->hidden('author_id') to $form->input('author_id') solved my problem. I'm using cake 1.2 too.

On Sunday, July 5, 2009 at 6:53:45 AM UTC+2, centr0 wrote:
my db is designed as one author can have many books.  books belongsto
authors.  when i call generateList() i get a 1064 SQL error.

here is my add action:

public function add() {
        if(!empty($this->data)) {
            $this->Book->create();
            $this->Book->save($this->data);
            $this->redirect(array('action' => 'index'));
        }
        $authors = $this->Book->Author->generateList();
        $this->set('authors', $authors);
    }

and my view:

<?php echo $form->create('Book'); ?>
    <fieldset>
        <legend>Add a new book:</legend>
        <?php
            echo $form->input('isbn');
            echo $form->input('title');
            echo $form->input('description');
            echo $form->input('author_id');
        ?>
    </fieldset>
<?php echo $form->end('Submit'); ?>

the error msg is:
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

im using xampp on win xp so im guessing everything is up to date.  my
db_config uses mysqli.

any ideas?  thanks in advance for response.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: