Hi, all. Thanks Paul, for your time to help me in this ORM stuff. No authors
in Book find command.
Models
<?php
class Author extends AppModel
{
var $name = 'Author';
var $hasMany = 'Book';
}
?>
<?php
class Book extends AppModel
{ var $name = 'Book';
var $belongsTo = 'Author';
}
?>
Controllers
<?php
class AuthorsController extends AppController {
var $name = 'Authors';
function index() {
$this->Author->recursive = 1;
$authors = $this->Author->find('all');
$this->set('authors', $authors);
}
}
?>
<?php
class BooksController extends AppController {
var $name = 'Books';
function index() {
$this->Book->recursive = 1;
$books = $this->Book->find('all');
$this->set('books', $books);
}
}
?>
Finally, yes books have authors
No, I'm not using containable array.
Cheers
--
M.S. Mónico Briseño Cortés
Instructional Technologist Univ. Houston
Moodle Teacher Certificate
NTCM member
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en