欢迎使用skymvc框架,简单易用的php框架

skymvc是一款轻量、简单易用的php mvc框架,经过多个项目实践改良。

特点:

1.mvc架构

2.m、v、c之间可以互相调用

3.简单的路由控制 R("/index.php");

4.强大的模版,模版可以直接调用m和c内容

5.语言包支持

6.hook机制

7.数据缓存

8.全文索引

9.静态生成

控制器:

index.ctrl.php

<?php
class indexControl extends skymvc
{
	function __construct()
	{
		parent::__construct();
		$this->loadModel(array("article"));
	}

	public function onDefault()
	{
		$option=array();
 		$rscount=true;
		$data=$this->article->select($option,$rscount);
		$pagelist=$this->pagelist($rscount,20,APPINDEX."?m=index&a=default");
		$this->smarty->assign(array(
			"data"=>$data,
			"rscount"=>$rscount,
			"pagelist"=>$pagelist
		));
		$this->smarty->display("index.html");
	}
	
	public function onShow(){
		$id=get('id','i');
		$id && $data=$this->article->selectRow(array("where"=>"id=$id"));
		$this->smarty->assign(array(
			"data"=>$data
		));
		$this->smarty->display("show.html");
	}
	
	public function onAdd(){
		$id=get('id','i');
		$id && $data=$this->article->selectRow(array("where"=>"id=$id"));
		$this->smarty->assign(array(
			"data"=>$data
		));
		$this->smarty->display("add.html");
	}
	
	public function onSave(){
		$id=get_post("id","i");
		$data["title"]=get_post("title","h");
		$data["content"]=get_post("content","h");
		$data["dateline"]=time();
		if($id){
			$this->article->update($data,array('id'=>$id));
		}else{
			$this->article->insert($data);
		}
		$this->gomsg($this->lang["save_success"]);
	}
	
	public function onDelete(){
		$id=get_post("id","i");
		$this->article->delete("id=$id");
		$this->gomsg($this->lang["delete_success"]);
	}
}

?>

模型:article.model.php

<?php
class articleModel extends model
{
	public $base;
	function __construct(&$base)
	{
		parent::__construct($base);
		$this->base=$base;
		$this->table='article';
	}

	 
	
}

?>

View模版:

{include file="header.html"}
<table class="table table-bordered" width="100%">
	<tr>
    <td width="11%">ID</td>
    <td width="49%">标题</td>
    <td width="20%">发布时间</td>
    <td width="20%">操作</td>
    </tr>
    
    {foreach item=c from=$data}
    <tr>
    <td>{$c.id}</td>
    <td><a href="{R("$appindex?m=index&a=show&id=$c.id")}">{$c.title}</a></td>
    <td>{$c.dateline|date:Y-m-d H:i:s}</td>
    <td><a href="{R("$appindex?m=index&a=add&id=$c.id")}">编辑</a> 
    	<a href="{R("$appindex?m=index&a=delete&id=$c.id")}">删除</a></td>
    </tr>
    {/foreach}
</table>
{$pagelist}
{include file="footer.html"} 

QQ交流群:61469962
官方网站:http://www.skymvc.com 欢迎大家使用交流。

下载地址: http://www.skymvc.com/down.html

posted @ 2013-07-25 10:59  lrjxgl  阅读(602)  评论(0编辑  收藏  举报