图书管理系统(后端)--插入读者信息

1.插入函数文件dbop.php

query($query);

        if($result)
        {
            echo "ok";
            $conn->commit();
        }
        else
        {
            echo "error";
            $conn->rollback();
        }
    }
?>

2.api封装1.php文件

{unum};

    $row['name'] = $recv->{name};

    $row['pass'] = $recv->{pass};

    $row['conn'] = $recv->{conn};

    $row['role'] = $recv->{role};

    $row['sex'] = $recv->{sex};

    $row['rdate'] = $recv->{rdate};

    $row['edate'] = $recv->{edate};

    $row['bnum'] = $recv->{bnum};

    $row['vnum'] = $recv->{vnum};

    $row['flag'] = $recv->{flag};

    $conn = new mysqli("localhost", "niki", "niki", "niki") or dir("不能连接到mysql");

    $conn->autocommit(false);

    $conn->query("set names utf8");

    insert_niki_read_info($conn, $row);

    $conn->close();
?>

3.测试脚本read_info_add.sh

curl -H "Content-Type:application/json" -X POST --data '{
    "unum": "s201604051303",
    "name": "小辉",
    "pass": "abce",
    "conn": "15597920475",
    "role": 502,
    "sex": "M",
    "rdate": "2016-06-10",
    "edate": "2018-06-01",
    "bnum": "0",
    "vnum": "0",
    "flag": "0"
}' http://10.192.89.12/local/2/1.php

4.运行脚本

$ ./read_info_add.sh

5.运行结果查询

mysql> select * from NIKI_READ_INFO;
+-----+---------------+------+------+-------------+------+-----+------------+------------+------+------+------+
| rid | unum          | name | pass | conn        | role | sex | rdate      | edate      | bnum | vnum | flag |
+-----+---------------+------+------+-------------+------+-----+------------+------------+------+------+------+
|   3 | s201604051303 | 小辉 | abce | 15597920475 |  502 | M   | 2016-06-10 | 2018-06-01 |    0 |    0 | 0    |
+-----+---------------+------+------+-------------+------+-----+------------+------------+------+------+------+
1 row in set (0.00 sec)

你可能感兴趣的:(图书管理系统(后端)--插入读者信息)