In CakePhp, database tables are plural.
So create a table called posts, a controller called PostsController
(posts_controller.php) and a model called Post (post.php).
Read up on CakePhp naming conventions in the Cake book. :)
No need to create routes for that.
Controllers and tables are plural, models are singular.

On Oct 21, 2:56 pm, Vincent <vjaun...@gmail.com> wrote:
> Ok, I found the problem, its du to my apache conf, I made an error
> with rewrite_mod directives.
>
> On 21 oct, 13:09, Vincent <vjaun...@gmail.com> wrote:
>
> > Ok.
>
> > I configured a MySQL DB and created a table 'post'.
>
> > Added in app/routes.php:
> > Router::connect('/posts/', array('controller' => 'posts'));
>
> > Created app/controllers/posts_controller.php
> > <?php
> > class PostsController extends AppController {
> >   // var $name = 'Posts';
>
> >   function index() {
> >     $this->set('posts', $this->Post->find('all'););
> >   }
> > ?>
>
> > Created app/models/posts.php
> > <?php
> > class Post extends AppModel {
> >   var $name = 'Post';}
>
> > ?>
>
> > Created app/views/posts/index.ctp
> > <h1>Blog posts</h1>
> > <table>
> > <tr>
> > <th>Id</th>
> > <th>Title</th>
> > <th>Created</th>
> > </tr>
> > <?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>
>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to