There are two different methods in code1 and code2 to successfully save data in the database.However, the data can't be found after saving.but when I refresh the Web page,it can be found.
code1:
$obj = new Object;
$obj->object_id = $objectId;
$obj->object_lt_x = $objX;
$obj->object_lt_y = $objY;
$obj->object_width = $objWidth;
$obj->object_height = $objHeight;
$obj->image_id = $imageId;
$obj->type_id = $typeId;
if ($obj->save()) {
$obj_id = $obj->object_id;
$success = array('status' => 1,'message' => $type_name.'标记成功!','obj_id' => $obj_id);
return response()->json($success);
} else {
$error = array('status' => 0,'message' => $type_name.'标记失败!');
return response()->json($error);
}
code2:
$objectId = $this->createGuid();
$objWidth = 1;
$objHeight = 1;
$objX = 1;
$objY = 1;
$imageId = '258CCA7A-D239-7397-8948-5F744D06AD';
$typeId = '866D7AB4-594D-CB20-7172-5A69DB3B26';
$result = DB::insert('insert into objects (object_id, object_lt_x, object_lt_y, object_width,object_height,image_id,type_id) values (?, ?, ? , ? ,?,?,?)',
[$objectId, $objX,$objY,$objWidth,$objHeight,$imageId,$typeId]);
$object = DB::table('objects')->where('object_id',$objectId)->get();
var_dump($object);
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire