日期:2014-05-17  浏览次数:20529 次

本人借鉴其他PHP Framework 自己开发的一个Framework,请大家指点

本人借鉴其他PHP Framework如autocrud等,还有ror的思想.?自己开发的一个Framework

?

系统根据建好的数据库自动生成model、controller和view的各个文件:

?

本人是初学者,请大家多多指点

?

Model:

?

<?php
include "connect.php";
class users extends Connect{??
?function Add($data){
??$this->crud->users->insert($data);
?}
?function Select($orderby,$where,$currentpage,$paging){
??$this->crud->users->orderby = "$orderby";
??$this->crud->users->where = "$where";
??$paging==1 ? $this->crud->users->paging = true : $this->crud->users->paging = false;
??$this->crud->users->perpage = 2;
??$this->crud->users->currentpage = $currentpage;
??return $this->crud->users->select();
?}
?function Get($id){
??return $this->crud->users->get($id);
?}
?function Delete($id){
??return $this->crud->users->delete($id);
?}
?function Update($data,$id){
??return $this->crud->users->update($data, $id);
?}
}
?>

?

?

controller:

?

<?php
include ('models/users.php');
include ('smarty/template.php');
$tpl = new SmartTemplate("views/listusers.htm");
$users = new users;
$orderby = "";
$where = "";
$currentpage = $_GET['page'];
$userss = $users->Select($orderby,$where,$currentpage,0);
$rows = count($userss);
$userss = $users->Select($orderby,$where,$currentpage,1);
$i = 0;
if($rows > 0){
??? for($j = 0; $j < count($userss); $j++){
???? $i = 1-$i;
???? ($i==0) ? $bgcolor="#eff1f3" : $bgcolor="#feefd5";
???? $userss[$j][bgcolor] = $bgcolor;
?}
}
$tpl->assign(array(
"userss"=>$userss,
"rows"=>$rows));
$tpl->output();
?>

?

view:

?

<HTML>
<HEAD>
</HEAD>
<BODY>
<!-- IF rows="0" -->
没有您要查找的记录! <a href="addusers.php">新增..</a>
<!-- ELSE -->
<form name="form1">
共 {rows} 条记录 转到第&nbsp;<input name="page" size="3">&nbsp;页
&nbsp;<input type="submit" value="Go">&nbsp;<a href="addusers.php">新增..</a>
</form>
<table width="780">
<tr bgcolor="#FFCC66"><td>id</td><td>name</td><td>操作</td></tr>
<!-- BEGIN userss -->
<tr bgcolor={bgcolor}><td>{id}</td><td>{name}</td><td><a href=listusers.php?identity={id}&action=del>删除</a>&nbsp<a href=addusers.php?identity={id}>编辑</a>&nbsp<a href=viewusers.php?identity={id} target=_blank>查看</a></td></tr>
<!-- END userss -->
</table>
<!-- ENDIF -->
</BODY>
</HTML>

?

?