Skip to content

Instantly share code, notes, and snippets.

--
-- テーブルの構造 `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`password` char(40) COLLATE utf8_unicode_ci NOT NULL,
`created` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
<?php
class AppController extends Controller {
var $components = array('DebugKit.Toolbar');
}
?>
<div class="posts form">
<?php echo $form->create('Post');?>
<fieldset>
<legend><?php __('Edit Post');?></legend>
<?php
echo $form->input('id');
echo $form->input('title');
echo $form->input('body');
?>
</fieldset>
<div class="posts form">
<?php echo $form->create('Post');?>
<fieldset>
<legend><?php __('Add Post');?></legend>
<?php
echo $form->input('title');
echo $form->input('body');
?>
</fieldset>
<?php echo $form->end('Submit');?>
<div class="posts view">
<h2><?php __('Post');?></h2>
<dl><?php $i = 0; $class = ' class="altrow"';?>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $post['Post']['id']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Title'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<div class="posts index">
<h2><?php __('Posts');?></h2>
<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<table cellpadding="0" cellspacing="0">
<tr>
<?php
class PostsController extends AppController {
var $name = 'Posts';
var $helpers = array('Html', 'Form');
function index() {
$this->Post->recursive = 0;
$this->set('posts', $this->paginate());
}
<?php
class DATABASE_CONFIG {
var $default = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user',
'password' => 'pass',
'database' => 'workshop',
INSERT INTO posts (title, body, created) VALUES ('大阪', 'これは、記事の本文でっせー。', NOW());
INSERT INTO posts (title, body, created) VALUES ('また大阪か', 'そこに本文が続きまんがな。', NOW());
INSERT INTO posts (title, body, created) VALUES ('大阪の逆襲', 'こりゃほんまおもろいで!って、うそやねん〜', NOW());
--
-- テーブルの構造 `posts`
--
CREATE TABLE `posts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`body` text COLLATE utf8_unicode_ci NOT NULL,
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,