|
Ajax 增删改查数据库_UBtree增删改查
zbhjeymv3n32woe.png
(图片来源网络,侵删)
Ajax 增删改查数据库
1、增加数据
$.ajax({
type: "POST",
url: "addData.php",
data: { key1: "value1", key2: "value2" },
success: function(response) {
console.log("数据添加成功");
}
});
2、删除数据
$.ajax({
type: "POST",
url: "deleteData.php",
data: { id: "1" },
success: function(response) {
console.log("数据删除成功");
}
});
3、修改数据
$.ajax({
type: "POST",
url: "updateData.php",
data: { id: "1", key1: "newValue1", key2: "newValue2" },
success: function(response) {
console.log("数据修改成功");
}
});
4、查询数据
$.ajax({
type: "GET",
url: "getData.php",
data: { id: "1" },
success: function(response) {
console.log("查询到的数据为:", response);
}
});
UBtree 增删改查
1、增加节点
def insert(self, key):
if not self.root:
self.root = Node(key)
else:
self._insert(self.root, key)
2、删除节点
def delete(self, key):
self.root = self._delete(self.root, key)
3、修改节点
def update(self, old_key, new_key):
node = self.search(old_key)
if node:
node.key = new_key
4、查询节点
def search(self, key):
return self._search(self.root, key) |
|