当前位置:网站首页>Xunrui CMS custom data interface PHP executable code

Xunrui CMS custom data interface PHP executable code

2022-06-22 20:47:00 Blue dream Maple Creek



 Xunrui CMS Custom data interface -php Executable code

When the interface of the system itself Not meeting your needs when , You can customize the interface and the server code here ( This type requires php Development experience ).


Usage example

Query all users , And back to username and email data

1、 Definition test.php Interface file :./dayrui/App/Httpapi/Api/test.php

<?php/** * api  Sample file  *  A variable is introduced  * $return  Represents the standard return variable  */$return = []; //  Return the data //  Query all members , And back to username and email$data = \Phpcmf\Service::M()->table('member')->getAll();if ($data) {    foreach ($data as $r) {        $return[] = [            'id' => $r['id'],            'username' => $r['username'],        ];    }}

Write your... Here php Code , Query statement , Submit statements, etc .


It can also be written like this :

\Phpcmf\Service::C()->_json(1, ' My return script succeeded ', [' Returns an array of ']); //  Successful writing \Phpcmf\Service::C()->_json(0, ' My return script failed '); //  Failure is written in 



2、 Background selection test.php file


 Xunrui CMS Custom data interface -php Executable code


3、 When testing the request result , The return format is :

array(3) {  ["code"]=>  int(1)  ["msg"]=>  string(2) "ok"  ["data"]=>  array(13) {    [0]=>    array(2) {      ["id"]=>      string(1) "1"      ["username"]=>      string(5) "admin"    }    ......

This type Yes php The skill requirements are relatively high , If you encounter an execution error, you can Error log Examination result .

原网站

版权声明
本文为[Blue dream Maple Creek]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206221907316043.html