日期:2014-05-17 浏览次数:20531 次
<?php
class BooksController extends AppController
{
var $name='Books';
var $help='form';
function index() {
$this->Book->recursive = 1;
$books = $this->Book->find('all',array('field'=>array('Book.isbn','Book.title','Author.name')));
$this->set('books', $books);
}
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);
}
}
?>