试着尝试了一下用PHP来制作json API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<?php header('Content-type:text/json'); /** * Created by PhpStorm. * User: Jason * Date: 14-3-21 * Time: 下午9:58 */ //加载数据库类 include_once('../Add-ons/PHP-MySQL-Class-master/class.MySQL.php'); //定义数据库对象 $oMySQL = new MySQL('aftools', 'root', 'tEGMxuY6hTCdQSQL', 'localhost'); $rel = $oMySQL->ExecuteSQL('SELECT COUNT(*) FROM `shops`'); if($rel) $sql_status = 'success'; if(!$rel) $sql_status = 'error'; $rel = array( 'sql-status' => $sql_status, 'total-num' => $rel['COUNT(*)'] ); $json = json_encode($rel); echo $json; |
There are no comments yet