• CakePHP学习之二 简单的测试例子


    1.首先建立自己的表

    SET FOREIGN_KEY_CHECKS=0;
    -- ----------------------------
    -- Table structure for posts
    -- ----------------------------
    CREATE TABLE `posts` (
      `id` int(10) unsigned NOT NULL auto_increment,
      `title` varchar(50) default NULL,
      `body` text,
      `created` datetime default NULL,
      `modified` datetime default NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=gbk;

    -- ----------------------------
    -- Records
    -- ----------------------------
    INSERT INTO `posts` VALUES ('1', 'The title', 'This is the post body.', '2009-06-16 10:04:05', null);
    INSERT INTO `posts` VALUES ('2', 'A title once again', 'And the post body follows.', '2009-06-16 10:04:05', null);
    INSERT INTO `posts` VALUES ('3', 'Title strikes back', 'This is really exciting! Not.', '2009-06-16 10:04:05', null);
    INSERT INTO `posts` VALUES ('4', '3232', '33', '2009-06-16 06:03:06', '2009-06-16 06:03:06');

    2.在models里添加post.php文件

    <?php
    class Post extends AppModel{
        var $name = 'Post';
    }
    ?>

    3.在controllers目录下添加 posts_Controller.php

    <?php
    class PostsController extends AppController{
       var $name = 'Posts';
      var $scaffold;

     }
    ?>

     4.在ie里输入http://127.0.0.1:8081/posts

    你可以看到下面的效果

     

  • 相关阅读:
    android —— textview解析html富文本
    android toolbar及可折叠标题栏
    dp——cf1327F
    cf1327D,E——组合数学
    技能表自查
    python 之禅 import this
    转--Python标准库之一句话概括
    python 爆破
    python -- 算法
    python 代码模板
  • 原文地址:https://www.cnblogs.com/meetweb/p/1504427.html
Copyright © 2020-2023  润新知