Model
<?php
namespace App\index\model;
Use Think\model;
Class Test extends model{
}
Controller
<?php
namespace App\index\controller;
Use App\index\model\test;
Use Think\controller;
Use think\db;
Class Model extends controller{public
function test () {
$test = new test;
$test->user_id= ' 0001 ';
$test->user_name= ' Tuzi ';
if ($test->save ()) {
echo "success";
} else{
echo "error";
}
$res = db::table (' Test ')->select ();
Dump ($res);
}
Run Results
Success Array (5) {[0] => Array (3) {[' _id '] => object (Mongodb\bson\objectid) #20 (1) {[' oid '] => str
ing () "5A522B025BFB248E032A9AB1"} ["user_id"] => string (4) "0001" ["User_name"] => string (4) "Tuzi" [1] => Array (3) {[' _id '] => object (Mongodb\bson\objectid) #21 (1) {[' oid '] => string (?) 5a522b4 C5bfb248dff003ea2 '} [' user_id '] => string (4) "0001" ["User_name"] => string (4) "Tuzi"} [2] => a Rray (3) {["_id"] => object (Mongodb\bson\objectid) #22 (1) {["OID"] => string () 5a522b505bfb248dff003ea 3 "} [" user_id "] => string (4)" 0001 "[" User_name "] => string (4)" Tuzi "} [3] => Array (3) {[" _id "] => object (Mongodb\bson\objectid) #23 (1) {[" OID] => string "5A522B515BFB248DFF003EA4"} ["U ser_id "] => string (4)" 0001 "[" User_name "] => string (4)" Tuzi "} [4] => Array (3) {[" _id "] => obje CT (Mongodb\bson\objectid) #24 (1) {["OID"] => string (5a522b575bfb248e012e17e1)} [user_id] => string (4) "0001" ["US Er_name "] => string (4)" Tuzi "}} 0.038957s Showpagetrace