栏目分类:
子分类:
返回
终身学习网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
终身学习网 > IT > 软件开发 > 后端开发 > PHP > php开源框架 > tpAdmin

示例三 - 从数据表生成 - tpAdmin 文档

tpAdmin 更新时间:发布时间: 百科书网 趣学号

## 开始使用
0. 在从数据表生成选项后下拉框里选择需要从表生成的数据表,页面会刷新,载入数据表字段
1. 页面会根据表名自动生成一个控制器名,但对于多级控制器,默认生成的控制器名是错误的,需要手动修改,然后填写后面的控制器标题
2. 删除表单元素里的不需要的字段,例如 `id`
3. 完善表单元素信息
4. 勾选需要生成的首页菜单
5. 勾选是否创建模型和验证器
6. 点击生成

![](https://box.kancloud.cn/e5b919c6f4714b827b076e22497b901f_1838x963.png)

![](https://box.kancloud.cn/ca9637421c67758524616282f8f47d4d_1835x963.png)

![](https://box.kancloud.cn/d091535ea9bede78a05800111a7409a8_1834x260.png)

![](https://box.kancloud.cn/d6040230a1f30f9b71a5718618854e62_1840x965.png)

![](https://box.kancloud.cn/8b42f2682eb2ede5e2b36c617644e9da_1850x963.png)

>[info] 以下代码、日志全部是自动生成,没有做任何修改,包括缩进,严格的缩进非常方便二次编辑和查阅

## 生成文件

### controller/File.php
```
namespace appadmincontroller;

thinkLoader::import('controller/Controller', thinkConfig::get('traits_path') , EXT);

use appadminController;

class File extends Controller
{
use appadmintraitscontrollerController;
// 方法黑名单
protected static $blacklist = [];

protected static $isdelete = false;

protected function filter(&$map)
{
if ($this->request->param("name")) {
$map['name'] = ["like", "%" . $this->request->param("name") . "%"];
}
if ($this->request->param("original")) {
$map['original'] = ["like", "%" . $this->request->param("original") . "%"];
}
if ($this->request->param("domain")) {
$map['domain'] = ["like", "%" . $this->request->param("domain") . "%"];
}
if ($this->request->param("type")) {
$map['type'] = ["like", "%" . $this->request->param("type") . "%"];
}
}
}
```

### view/file/index.html
```
{extend name="template/base" /}
{block name="content"}




{tp:menu menu="add" /}


共有数据 :{$count ?? '0'}

















{volist name="list" id="vo"}











{/volist}

目录 文件名 原文件名 域名 文件类型 {:sort_by('文件大小','size')} {:sort_by('修改时间','mtime')} 操作
{$vo.cate} {$vo.name|high_light=$Request.param.name} {$vo.original|high_light=$Request.param.original} {$vo.domain|high_light=$Request.param.domain} {$vo.type|high_light=$Request.param.type} {$vo.size} {$vo.mtime}
{tp:menu menu='sedit' /}
{tp:menu menu='sdeleteforever' /}

{$page ?? ''}

{/block}

```
>[info] 因为没有选择创建回收站(recyclebin.html)自动合并 th.html、td.html、form.html 到 index.html 文件中

### view/file/edit.html
```
{extend name="template/base" /}
{block name="content"}



{/block}
{block name="script"}


{/block}
```
### view/file/config.php
```

return array (
'module' => 'admin',
'menu' =>
array (
0 => 'add',
),
'create_config' => true,
'controller' => 'File',
'title' => '文件',
'form' =>
array (
2 =>
array (
'title' => '目录',
'name' => 'cate',
'type' => 'select',
'option' => '',
'default' => '',
'search_type' => 'text',
'require' => '1',
'validate' =>
array (
'datatype' => '*',
'nullmsg' => '',
'errormsg' => '',
),
),
3 =>
array (
'title' => '文件名',
'name' => 'name',
'type' => 'text',
'option' => '',
'default' => '',
'search' => '1',
'search_type' => 'text',
'require' => '1',
'validate' =>
array (
'datatype' => '*',
'nullmsg' => '',
'errormsg' => '',
),
),
4 =>
array (
'title' => '原文件名',
'name' => 'original',
'type' => 'text',
'option' => '',
'default' => '',
'search' => '1',
'search_type' => 'text',
'require' => '1',
'validate' =>
array (
'datatype' => '*',
'nullmsg' => '',
'errormsg' => '',
),
),
5 =>
array (
'title' => '域名',
'name' => 'domain',
'type' => 'text',
'option' => '',
'default' => '',
'search' => '1',
'search_type' => 'text',
'validate' =>
array (
'datatype' => '',
'nullmsg' => '',
'errormsg' => '',
),
),
6 =>
array (
'title' => '文件类型',
'name' => 'type',
'type' => 'select',
'option' => '',
'default' => '',
'search' => '1',
'search_type' => 'text',
'validate' =>
array (
'datatype' => '',
'nullmsg' => '',
'errormsg' => '',
),
),
7 =>
array (
'title' => '文件大小',
'name' => 'size',
'type' => 'number',
'option' => '',
'default' => '',
'sort' => '1',
'search_type' => 'text',
'require' => '1',
'validate' =>
array (
'datatype' => '*',
'nullmsg' => '',
'errormsg' => '',
),
),
8 =>
array (
'title' => '修改时间',
'name' => 'mtime',
'type' => 'text',
'option' => '',
'default' => '',
'sort' => '1',
'search_type' => 'text',
'validate' =>
array (
'datatype' => '',
'nullmsg' => '',
'errormsg' => '',
),
),
),
);

```

转载请注明:文章转载自 www.051e.com
本文地址:http://www.051e.com/it/214039.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 ©2023-2025 051e.com

ICP备案号:京ICP备12030808号