当前位置:网站首页>迅睿CMS 自定义数据接口-php执行文件代码
迅睿CMS 自定义数据接口-php执行文件代码
2022-06-22 19:07:00 【蓝梦枫溪】

当系统本身的接口不满足你的需求时,你可以在这里进行接口自定义服务端代码(本类型需要有php的开发经验)。
用法举例
查询全部用户,并返回username和email数据
1、定义test.php接口文件:./dayrui/App/Httpapi/Api/test.php
<?php/** * api 示例文件 * 变量介绍 * $return 表示标准返回变量 */$return = []; // 返回数据// 查询全部会员,并返回username和email$data = \Phpcmf\Service::M()->table('member')->getAll();if ($data) { foreach ($data as $r) { $return[] = [ 'id' => $r['id'], 'username' => $r['username'], ]; }}这里就写入你的php代码,查询语句,提交语句等等。
中途返回也可以这样写:
\Phpcmf\Service::C()->_json(1, '我的返回脚本成功了', ['返回数组']); // 成功写法\Phpcmf\Service::C()->_json(0, '我的返回脚本失败了'); // 失败写法2、后台选择test.php文件

3、测试请求结果时,返回格式为:
array(3) { ["code"]=> int(1) ["msg"]=> string(2) "ok" ["data"]=> array(13) { [0]=> array(2) { ["id"]=> string(1) "1" ["username"]=> string(5) "admin" } ......本类型对php技能要求比较高,如果遇到执行错误可以在错误日志检查结果。
边栏推荐
- NFT 中可能存在的安全漏洞
- [in depth understanding of tcapulusdb technology] form creation and approval of document acceptance
- 3个月自学自动化测试,薪资从4.5K到15K,鬼知道我经历了什么?
- [resolved] -go_ out: protoc-gen-go: Plugin failed with status code 1.
- 软件压力测试有哪些方法,如何选择软件压力测试机构?
- [deeply understand tcapulusdb technology] tcapulusdb table management - clean up table
- Can financial products be redeemed on weekends?
- Hash table (hash table)
- Cross domain cors/options
- [in depth understanding of tcaplus DB technology] Introduction to tcaplus JDBC development
猜你喜欢
![[deeply understand tcapulusdb technology] view the online operation of tcapulusdb](/img/6f/2d62030e631e3085acf72951f2416f.png)
[deeply understand tcapulusdb technology] view the online operation of tcapulusdb

client-go gin的简单整合十一-Delete

如何低成本快速搭建企业知识库?

Introduction of neural networks for Intelligent Computing (Hopfield network DHNN, CHNN)

软件压力测试有哪些方法,如何选择软件压力测试机构?
![[deeply understand tcapulusdb knowledge base] common problems in deploying tcapulusdb local](/img/2b/3ab5e247ac103728b4d3579c3c5468.png)
[deeply understand tcapulusdb knowledge base] common problems in deploying tcapulusdb local

Please describe the whole process from entering a URL in the browser to rendering the page.

【深入理解TcaplusDB技术】查看TcaplusDB线上运行情况

Search, insert and delete of binary sort tree

基于Sentinel的高可用限流系统的Grafana报表展示
随机推荐
Three dimensional world helps the laboratory to consolidate the complete quality system management
NFT 中可能存在的安全漏洞
3个月自学自动化测试,薪资从4.5K到15K,鬼知道我经历了什么?
Precautions for Apollo use
Random talk about redis source code 122
Simple integration of client go gin 11 delete
Nestjs integrates config module and Nacos to realize configuration unification
【Proteus仿真】NE555延时电路
R语言data.table导入数据实战:data.table数据列名称的重命名(rename)
Scheduling with Testing
B tree code (C language)
I wrote a telnet command myself
[in depth understanding of tcapulusdb technology] tcapulusdb adds a new business cluster cluster
Using span method to realize row merging of multi-layer table data
web技术分享| 【高德地图】实现自定义的轨迹回放
Containerd容器运行时(2):yum安装与二进制安装,哪个更适合你?
[deeply understand tcapulusdb technology] tcapulusdb table management - clean up table
IDEA写jsp代码报错,但是正常运行解决
元宇宙中的云计算,提升你的数字体验
什么?你居然不会微信分身