+ -
当前位置:首页 → 问答吧 → 表单提交 create 没数据 add 不成功

表单提交 create 没数据 add 不成功

时间:2011-08-17

来源:互联网



我写了一个简单的表单提交 但是 create 的时候没有数据 add也不成功  下面是我的代码  

lib/ArticleAction.class.php
  1. class ArticleAction extends Action {
  2.     public function _initialize(){
  3.         header('Content-Type:text/html; charset=utf-8');
  4.     }


  5.     public function add() {
  6.         $this->display();
  7.     }

  8.     public function insert() {
  9.         $Article = new ArticleModel();
  10.         $res = $Article->create();-------------------------------------------这里没有数据 $res是空的
  11.         if (!empty($res)) {
  12.             dump($res);                 -------------------------------------------这里没有数据 $res是空的
  13.         } else {
  14.             echo $Article->getError();
  15.         }
  16.     }

  17. }
复制代码
tpl/Article/add.html
  1. <form method="post" action='__URL__/insert'>
  2.                 文章标题:<input type="text" name="article_name" /><br />
  3.                 文章内容:<textarea rows="5" cols="30" name="content"></textarea><br />
  4.                 <input type="submit" value="添加文章" />
  5.             </form>
复制代码
model
ArticleModel.class.php
  1. class ArticleModel extends Model{
  2.     protected $_validate=array(
  3.         array('article_name','require','文章标题必需填写'),
  4.         array('content','require','文章内容不能为空'),
  5.     );
  6. }
复制代码

作者: zzphper   发布时间: 2011-08-17

哪个大侠知道啊 ,还是我说的不你们没看明白 ?

作者: zzphper   发布时间: 2011-08-17

热门下载

更多