The name of the table in my database is "posts" that is the case and
the plurality. The columns are exactly as follows:
id, title, body, created, modified
My model code is this:
from /models/post.php:
<?php
class Post extends AppModel
{
var $name = 'Post';
}
?>
My controller code is this:
from controllers/posts_controller.php:
<?php class PostsController extends AppController
{
var $name = 'Posts';
function index()
{
$this->set('posts', $this->Post->findall());
}
}
?>
My view is this:
from /views/posts/index.thtml:
<h1>Blog posts</h1>
<table>
<tr><th>Id</th><th>Title</th><th>Created</th></tr>
<!-- Here's where we loop through our $posts array, printing out post
info -->
<?php foreach ($posts as $post): ?>
<tr>
<td><?php echo $post['Post']['id']; ?></td>
<td><?php echo $html->link($post['Post']['title'],
"/posts/view/".$post['Post']['id']); ?></td>
<td><?php echo $post['Post']['created']; ?></td>
</tr><?php endforeach; ?>
</table>
Is there anything else you might need?
thanks,
Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---