时间:2021-07-01 10:21:17 帮助过:37人阅读
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);
}
}
?>