zoukankan      html  css  js  c++  java
  • 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

    你可以看到下面的效果

     

  • 相关阅读:
    java和.NET的比较
    联想笔记本不能无线上网
    js根据给定的日期计算当月有多少天
    jQuery中live()变更
    C#操作xml文件
    SQL server的with的用法(一)
    jquery拖拽实现UI设计组件
    自定义弹出框
    第一个超级简单Node.js实例
    windows 下使用redis
  • 原文地址:https://www.cnblogs.com/meetweb/p/1504427.html
Copyright © 2011-2022 走看看