Merge remote-tracking (subtree) branch 'PracticingPhp/master'

This commit is contained in:
Dan Buch
2012-03-03 20:18:34 -05:00
905 changed files with 218528 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
<?php
class PostsController extends AppController {
public $helpers = array("Html", "Form");
public $name = "Posts";
function index() {
$this->set("posts", $this->Post->find("all"));
}
function view($id = null) {
$this->Post->id = $id;
$this->set("post", $this->Post->read());
}
function add() {
if (!empty($this->data)) {
if ($this->Post->save($this->data)) {
$this->Session->setFlash("Your post has been saved.");
$this->redirect(array("action" => "index"));
}
}
}
function delete($id) {
if ($this->Post->delete($id)) {
$this->Session->setFlash("The post with id: " . $id . " has been deleted");
$this->redirect(array("action" => "index"));
}
}
function edit($id = null) {
$this->Post->id = $id;
if (empty($this->data)) {
$this->data = $this->Post->read();
} else {
if ($this->Post->save($this->data)) {
$this->Session->setFlash("Your post has been updated");
$this->redirect(array("action" => "index"));
}
}
}
}
?>