国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

通過(guò)HTML網(wǎng)頁(yè)對(duì)mysql數(shù)據(jù)庫(kù)進(jìn)行增刪改查(CRUD實(shí)例)

這篇具有很好參考價(jià)值的文章主要介紹了通過(guò)HTML網(wǎng)頁(yè)對(duì)mysql數(shù)據(jù)庫(kù)進(jìn)行增刪改查(CRUD實(shí)例)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

首先我們得了解一下大致的架構(gòu) ,如下:

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

我們采用自底向上的方式進(jìn)行開(kāi)發(fā),

一、先寫(xiě)mysql數(shù)據(jù)庫(kù)

二、再寫(xiě)java后端(Spring MVC架構(gòu))(這個(gè)是什么東西不懂不要緊,跟著步驟做就行了)

三、最后寫(xiě)前端頁(yè)面(HTML)

一、 Mysql數(shù)據(jù)庫(kù)部分

我們要通過(guò)網(wǎng)頁(yè)對(duì)數(shù)據(jù)庫(kù)進(jìn)行開(kāi)發(fā),那么我們需要先準(zhǔn)備數(shù)據(jù)庫(kù)。

為了方便開(kāi)發(fā),直接用navicat來(lái)創(chuàng)建數(shù)據(jù)庫(kù),名字叫做crud,字符集為utf8

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

接著在數(shù)據(jù)庫(kù)中建立數(shù)據(jù)表,我們以學(xué)生信息為例,建立一個(gè)名字叫做student的數(shù)據(jù)表?

字段列表如下:

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?順便向數(shù)據(jù)庫(kù)中添加一些數(shù)據(jù)

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

這樣,我們第一部分就做好了,點(diǎn)支煙獎(jiǎng)勵(lì)一下自己~~

二、 編寫(xiě)java后端代碼

1.打開(kāi)IDEA,?新建spring項(xiàng)目

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?勾選web依賴(lài),就勾這個(gè)就好了

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?點(diǎn)擊完成后,如果報(bào)錯(cuò)就打開(kāi)這個(gè)鏈接:

IDEA創(chuàng)建springboot項(xiàng)目時(shí)提示https://start.spring.io初始化失敗_暮晨丶的博客-CSDN博客

?2.編寫(xiě)pom.xml文件

我們先找到這個(gè)“dependencies”標(biāo)簽

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?在這個(gè)標(biāo)簽內(nèi)添加依賴(lài)坐標(biāo)。

這個(gè)文件就是項(xiàng)目用到的外部依賴(lài),我們分析一下:

連接mysql數(shù)據(jù)庫(kù)我們需要添加驅(qū)動(dòng):

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

為了簡(jiǎn)化交互我們還需要添加mybatis的依賴(lài)坐標(biāo)

        <dependency>
            <!--Springboot和MyBatis整合得ar包坐標(biāo)-->
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.3</version>
        </dependency>

還有和前端交互用?的thymeleaf依賴(lài)坐標(biāo)

        <dependency>
            <!--和前端交互用的-->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

還有一些雜七雜八好用的依賴(lài)

        <dependency>
            <!--德魯伊數(shù)據(jù)源坐標(biāo)-->
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.2.8</version>
        </dependency>

        <dependency>
            <!--注解開(kāi)發(fā)自動(dòng)導(dǎo)入的依賴(lài)   @Data那種 -->
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

最后結(jié)果:?

?javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

然后刷新maven pom文件就編寫(xiě)好了?

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

3.建包(3+1=4個(gè)包)

MVC架構(gòu):controller、service、mapper

存放實(shí)體類(lèi)的包:pojo

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?4.在pojo下建立實(shí)體類(lèi),類(lèi)的屬性要和數(shù)據(jù)表的字段對(duì)應(yīng)

在pojo下創(chuàng)建一個(gè) Student類(lèi),類(lèi)上面添加三個(gè)注解,這三個(gè)注解的作用分別是

添加:get set方法、有參構(gòu)造方法、無(wú)參構(gòu)造方法

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?5. 配置數(shù)據(jù)庫(kù)連接信息,通過(guò)yml文件(里面的縮進(jìn)要格外注意,縮進(jìn)一定要和我寫(xiě)的一樣)

#數(shù)據(jù)庫(kù)連接信息
spring:
  datasource:
    username: root
    password: 2633
    url: jdbc:mysql://localhost:3306/crud?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8
    driver-class-name: com.mysql.jdbc.Driver
    type: com.alibaba.druid.pool.DruidDataSource

?結(jié)果:

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?5. 編寫(xiě)mapper層

(1)在mapper中創(chuàng)建接口 名字為StudetMapper

(2)在接口中添加注解 @Mapper

?(3)?在接口中編寫(xiě)增刪改查的方法

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?6.編寫(xiě)SQL

(1)先裝一個(gè) mybatis的插件

?javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

(2)在下面這個(gè)路徑中先建立一個(gè)mapper目錄,再創(chuàng)建一個(gè)StudentMapper.xml文件?

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.example.crud.mapper.StudentMapper">



</mapper>

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?好了之后屏幕會(huì)有藍(lán)色頭繩的小鳥(niǎo)javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?點(diǎn)擊小鳥(niǎo),就會(huì)跳轉(zhuǎn)到StudentMapper接口,這時(shí)我們可以看到接口方法報(bào)錯(cuò)了

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?(3)在mapper標(biāo)簽中編寫(xiě)sql語(yǔ)句

把鼠標(biāo)光標(biāo)放到紅色的地方,按快捷鍵 alt + 回車(chē) 就可以創(chuàng)建寫(xiě)sql的地方了,然后再標(biāo)簽里邊編寫(xiě)sql

(4)連接數(shù)據(jù)庫(kù)

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?之后就不會(huì)報(bào)錯(cuò)了。

繼續(xù)編寫(xiě)SQL語(yǔ)言,重復(fù)返回接口按ALT+回車(chē)+回車(chē)編寫(xiě)全部的SQL

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?直到這里沒(méi)有報(bào)錯(cuò),并且有紅色頭繩小鳥(niǎo)

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?7.在application.yml文件中添加mybatis信息

#配置Mybatis映射路徑
mybatis:
  mapper-locations: classpath:mapper/*.xml
  type-aliases-package: com.example.StudentDemo.pojo

?配置端口為80

#配置端口
server:
  port: 80

結(jié)果

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?8. 編寫(xiě)service層

(1)在類(lèi)外面添加@Service注解

(2)在類(lèi)中添加

    @Autowired
    StudentMapper studentMapper;

(3)調(diào)用studentMapper的接口方法

結(jié)果截圖:?

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

9.編寫(xiě)controller層和前端頁(yè)面

注:到這里是我認(rèn)為最難的部分,如果前面沒(méi)有做單元測(cè)試的話(huà) 會(huì)有可能報(bào)錯(cuò),所以單元測(cè)試很重要

(1)在controller中創(chuàng)建StudentController類(lèi) ,在類(lèi)外面注解為@Controller

(2)在類(lèi)中添加注解@Autowired? 調(diào)用StudentService

?StudentController代碼

package com.example.crud.controller;

import com.example.crud.pojo.Student;
import com.example.crud.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

@Controller
public class StudentController {
    @Autowired
    StudentService studentService;

    @GetMapping("/toindex")
    public String toindex(){
        return "index";
    }

    //查詢(xún)所有頁(yè)面
    @GetMapping("/findStudentList")
    public String findStudentList(Model model){
        List<Student> studentList=studentService.findAllStudent();
        //傳進(jìn)去的是一個(gè)鍵值對(duì)
        model.addAttribute("studentList",studentList);//傳進(jìn)前端的東西
        //返回值==html文件名
        return "findStudentList";
    }

    //跳轉(zhuǎn)到添加頁(yè)面
    @GetMapping("/toaddStudent")
    public String toaddStudent(){
        //返回值為文件名
        return "addStudent";
    }

    //真正執(zhí)行添加
    @PostMapping("/addStudent")
    public String addStudent(Student student)
    {
        studentService.addStudent(student);
        //跳轉(zhuǎn)到哪里(文件名)
        return "redirect:/findStudentList";
    }

    @GetMapping("/toupdateStudent/{id}")
    public String toupdateStudent(@PathVariable("id")String id, Model model){
        //先找到被修改的對(duì)象
        Student student=studentService.findStudentById(id);
        //將對(duì)象保存到model中
        model.addAttribute("student",student);
        //html文件名
        return "updateStudent";
    }

    @PostMapping("/updateStudent")
    public String updateStudent(Student student){
        //獲取當(dāng)前頁(yè)面學(xué)生信息,傳入按照id修改學(xué)生信息的Service,進(jìn)行信息修改
        studentService.updateStudent(student);
        return "redirect:/findStudentList";
    }

    @GetMapping("/deleteStudent/{id}")
    public String deleteStudent(@PathVariable("id")String id){
        studentService.deleteStudent(id);
        return "redirect:/findStudentList";
    }
}

?結(jié)果截圖

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

(3)編寫(xiě)首頁(yè)index.html

<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<a th:href="@{/findStudentList}">查詢(xún)信息</a>
</body>
</html>

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?(4)編寫(xiě)查詢(xún)所有頁(yè)面 findStudentList.html

<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<!--/*@thymesVar id="student" type="com.example.crud.pojo.Student"*/-->
<!--/*@thymesVar id="studentList" type="com.example.crud.controller"*/-->
<head>
    <meta charset="UTF-8">
    <title>查詢(xún)所有</title>
</head>
<body>
<table border="1">
    <tr><!--列-->
        <th>學(xué)號(hào)</th>
        <th>名字</th>
        <th>性別</th>
        <th>年齡</th>
        <th>籍貫</th>
        <th>操作</th>
    </tr>
    <tr th:each="student:${studentList}">
        <td th:text="${student.getId}"></td>
        <td th:text="${student.getName()}"></td>
        <td th:text="${student.getSex()}"></td>
        <td th:text="${student.getAge()}"></td>
        <td th:text="${student.getAddress()}"></td>
        <td>
            <a  role="button" th:href="@{/toupdateStudent/${student.getId()}}">修改</a>
            <a  role="button" th:href="@{/deleteStudent/${student.getId()}}">刪除</a>
        </td>
    </tr>
</table>
<div >
    <a  role="button" th:href="@{/toaddStudent}">添加員工</a>
    <a  role="button" th:href="@{/toindex}">返回首頁(yè)</a>
</div>
</body>
</html>

?javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?

? (5)編寫(xiě)修改頁(yè)面?

<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<!--/*@thymesVar id="student" type="com.example.crud.pojo.Student"*/-->
<head>
    <meta charset="UTF-8">
    <title>修改頁(yè)面</title>
</head>
<body>
<div >
    <form th:action="@{/updateStudent}" method="post">
        <div >
            <label >ID</label>
            <input type="text" name="id" th:value="${student.getId()}" class="form-control" placeholder="請(qǐng)輸入該學(xué)生的id">
        </div>
        <div class="form-group">
            <label >姓名</label>
            <input type="text" name="name" th:value="${student.getName()}" class="form-control" placeholder="請(qǐng)輸入修改后的姓名">
        </div>
        <div class="form-group">
            <label >性別</label>
            <input type="text" name="sex" th:value="${student.getSex()}" class="form-control" placeholder="請(qǐng)輸入修改后的性別">
        </div>
        <div class="form-group">
            <label >年齡</label>
            <input type="text" name="age" th:value="${student.getAge()}" class="form-control" placeholder="請(qǐng)輸入修改后的年齡">
        </div>
        <div class="form-group">
            <label >地址</label>
            <!--/*@thymesVar id="student" type="com.example.crud.pojo.Student"*/-->
            <input type="text" name="address" th:value="${student.getAddress()}" class="form-control" placeholder="請(qǐng)輸入修改后的地址">
        </div>

        <button type="submit" class="btn btn-default">保存</button>
        <a role="button" th:href="@{/findStudentList}">查詢(xún)員工</a>
        <a  role="button" th:href="@{/toindex}">返回首頁(yè)</a>
    </form>
</div>
</body>
</html>

?截圖

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?

?(6) 編寫(xiě)添加學(xué)生信息頁(yè)面

<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>添加頁(yè)面</title>

</head>
<body>
<div  >
    <form th:action="@{/addStudent}" method="post">
        <div>
            <br>
            <label >ID</label>
            <input  type="text" name="id"  placeholder="請(qǐng)輸入該員工的id">
        </div>

        <div>
            <label >姓名</label>
            <input type="text" name="name"  placeholder="">
        </div>

        <div>
            <label >性別</label>
            <select name="sex">
                <option value ="">null</option>
                <option value ="男">男</option>
                <option value ="女">女</option>
            </select>

        </div>

        <div>
            <label >年齡</label>
            <input type="text" name="age"  placeholder="">
        </div>

        <div>
            <label >地址</label>
            <input  type="text" name="address"  placeholder="">
        </div>

        <br>

        <button type="submit">點(diǎn)擊添加</button>
        <a class="myButton" th:href="@{/findStudentList}">查詢(xún)員工</a>
        <a class="myButton" th:href="@{/toindex}">返回首頁(yè)</a>
    </form>


</div>

</body>
</html>

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

? ? ? ? ? 這樣 整個(gè)項(xiàng)目就寫(xiě)完了

???????三、測(cè)試運(yùn)行

成功開(kāi)啟服務(wù)截圖:

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?開(kāi)啟服務(wù)失敗截圖:

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?解決辦法有兩個(gè):

1.修改端口號(hào) ,在yml文件中?

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

2. 殺死當(dāng)前80端口的進(jìn)程

win+r 進(jìn)入命令行 輸入

netstat -ano

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?輸入

taskkill /pid 17156 -f

?javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?這樣就可以繼續(xù)啟動(dòng)服務(wù)了

啟動(dòng)完成后打開(kāi)瀏覽器,輸入 127.0.0.1 回車(chē)

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?這樣就訪(fǎng)問(wèn)到了 index.html頁(yè)面

?javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?點(diǎn)擊查詢(xún)信息,就訪(fǎng)問(wèn)到了 findStudentList.html頁(yè)面的內(nèi)容,在頁(yè)面上展示了數(shù)據(jù)庫(kù)中的記錄

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

點(diǎn)擊修改? 跳轉(zhuǎn)到修改頁(yè)面 updateStudent.html

?javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?點(diǎn)擊刪除 直接刪除數(shù)據(jù)庫(kù)中的內(nèi)容

點(diǎn)擊 添加 跳轉(zhuǎn)到添加頁(yè)面 addStudent.html

javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis

?這樣就完成了CRUD實(shí)例的編寫(xiě),重點(diǎn)在Controller 和 交互前端交互的部分 有很多值得深究的地方,時(shí)間精力有限,不能一一解釋?zhuān)掖嬖谥T多BUG,有很多值得優(yōu)化的地方,mybatis可以寫(xiě)的更好

1.并發(fā)控制的問(wèn)題(一個(gè)線(xiàn)程把數(shù)據(jù)刪除了,另一個(gè)線(xiàn)程點(diǎn)擊了修改,這樣就會(huì)報(bào)錯(cuò))

2.添加一個(gè)空記錄,然后把這個(gè)空記錄進(jìn)行刪除(可以再前端頁(yè)面用一個(gè)正則表達(dá)式解決)

3.添加一條重復(fù)的記錄

????????僅記錄學(xué)習(xí)。。。。。不足之處還需要大哥批評(píng)指正

項(xiàng)目源代碼http://鏈接:https://pan.baidu.com/s/1oXVY-eD0ypziKzPcaKGAmg?pwd=1234 提取碼:1234

?javahtml連接數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù),mysql,java,spring,mybatis文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-785484.html

到了這里,關(guān)于通過(guò)HTML網(wǎng)頁(yè)對(duì)mysql數(shù)據(jù)庫(kù)進(jìn)行增刪改查(CRUD實(shí)例)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶(hù)投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Vue項(xiàng)目通過(guò)node連接MySQL數(shù)據(jù)庫(kù)并實(shí)現(xiàn)增刪改查操作

    Vue項(xiàng)目通過(guò)node連接MySQL數(shù)據(jù)庫(kù)并實(shí)現(xiàn)增刪改查操作

    1.創(chuàng)建Vue項(xiàng)目 Vue項(xiàng)目創(chuàng)建的詳細(xì)步驟,有需要的可移步這里 2.下載安裝需要的插件 下載express 下載cors,用于處理接口跨域問(wèn)題 下載mysql 下載axios 3.在項(xiàng)目中創(chuàng)建server文件夾,用于搭建本地服務(wù)器 新建/server/app.js,用于配置服務(wù)器相關(guān)信息 新建/server/db/index.js,用于配置數(shù)據(jù)庫(kù)

    2024年02月16日
    瀏覽(29)
  • PHP&MySQL基礎(chǔ)(一):創(chuàng)建數(shù)據(jù)庫(kù)并通過(guò)PHP進(jìn)行連接

    PHP&MySQL基礎(chǔ)(一):創(chuàng)建數(shù)據(jù)庫(kù)并通過(guò)PHP進(jìn)行連接

    PHP同樣可以對(duì)數(shù)據(jù)庫(kù)進(jìn)行連接,并且實(shí)現(xiàn)增刪改查、登錄注冊(cè)等功能,這一篇寫(xiě)一下怎么使用PHP去連接MySQL數(shù)據(jù)庫(kù) 目錄 一、創(chuàng)建數(shù)據(jù)庫(kù) 1.1 登錄頁(yè)面 1.2 創(chuàng)建數(shù)據(jù)庫(kù) 1.3 創(chuàng)建數(shù)據(jù)庫(kù)表 1.4 添加表字段 1.5 插入數(shù)據(jù) 1.6?導(dǎo)出和導(dǎo)入 二、PHP連接數(shù)據(jù)庫(kù) 2.1 通過(guò) mysqli() 進(jìn)行實(shí)例化 2.

    2024年02月03日
    瀏覽(25)
  • SpringBoot結(jié)合Vue.js+axios框架實(shí)現(xiàn)增刪改查功能+網(wǎng)頁(yè)端實(shí)時(shí)顯示數(shù)據(jù)庫(kù)數(shù)據(jù)(包括刪除多條數(shù)據(jù))

    SpringBoot結(jié)合Vue.js+axios框架實(shí)現(xiàn)增刪改查功能+網(wǎng)頁(yè)端實(shí)時(shí)顯示數(shù)據(jù)庫(kù)數(shù)據(jù)(包括刪除多條數(shù)據(jù))

    本文適用對(duì)象:已有基礎(chǔ)的同學(xué),知道基礎(chǔ)的SpringBoot配置和Vue操作。 在此基礎(chǔ)上本文實(shí)現(xiàn)基于SpringBoot和Vue.js基礎(chǔ)上的增刪改查和數(shù)據(jù)回顯、刷新等。 實(shí)現(xiàn)步驟: 第1步:編寫(xiě)動(dòng)態(tài)請(qǐng)求響應(yīng)類(lèi):在啟動(dòng)類(lèi)同父目錄下創(chuàng)建controller包,在包下創(chuàng)建DataController類(lèi),添加@RestController、

    2024年02月04日
    瀏覽(22)
  • Mysql 數(shù)據(jù)庫(kù)增刪改查

    MySQL是目前最流行的關(guān)系型數(shù)據(jù)庫(kù)。以下是MySQL數(shù)據(jù)庫(kù)的增刪改查操作。 在進(jìn)行增刪改查操作之前,需要先連接MySQL數(shù)據(jù)庫(kù)。使用以下命令進(jìn)行連接: 使用以下命令創(chuàng)建一個(gè)數(shù)據(jù)庫(kù): 使用以下命令創(chuàng)建一個(gè)數(shù)據(jù)表: 使用以下命令將數(shù)據(jù)插入到數(shù)據(jù)表中: 使用以下命令查詢(xún)數(shù)

    2024年02月13日
    瀏覽(23)
  • 數(shù)據(jù)庫(kù)--MySQL增刪改查

    數(shù)據(jù)庫(kù)-- 數(shù)據(jù)類(lèi)型 : http://t.csdn.cn/RtqMD 數(shù)據(jù)庫(kù)-- 三大范式、多表查詢(xún)、函數(shù)sql: http://t.csdn.cn/udJSG ?數(shù)據(jù)庫(kù)-- SQL的執(zhí)行順序: ? http://t.csdn.cn/MoJ4i? 在創(chuàng)建了數(shù)據(jù)庫(kù)和數(shù)據(jù)庫(kù)表之后,我們就可以在表中進(jìn)行數(shù)據(jù)操作了?;A(chǔ)操作分為 添加 刪除 修改 查詢(xún) 以上4 種操作又

    2024年02月13日
    瀏覽(16)
  • MySQL數(shù)據(jù)庫(kù) 【增刪改查】

    MySQL數(shù)據(jù)庫(kù) 【增刪改查】

    目錄 一、新增 ?指定列插入 一次插入多個(gè)數(shù)據(jù) 二、查詢(xún) 1、全列查詢(xún) 2、指定列查詢(xún)? 3、查詢(xún)字段為表達(dá)式 4、查詢(xún)的時(shí)候給列名/表達(dá)式 指定別名 5、查詢(xún)時(shí)去重 6、排序查詢(xún) 7、條件查詢(xún) 8、模糊查詢(xún) 9、空值查詢(xún) 10、分頁(yè)查詢(xún)? 三、修改? ? 四、刪除 ?SQL 最核心的操作就

    2024年02月16日
    瀏覽(19)
  • 【數(shù)據(jù)庫(kù)】MySQL表的增刪改查

    注釋?zhuān)涸赟QL中可以使用“–空格+描述”來(lái)表示注釋說(shuō)明 CRUD 即增加(Create)、查詢(xún)(Retrieve)、更新(Update)、刪除(Delete)四個(gè)單詞的首字母縮寫(xiě) 語(yǔ)法: 案例: 2.1 單行數(shù)據(jù) + 全列插入 2.2 多行數(shù)據(jù) + 指定列插入 查詢(xún)(Retrieve) 語(yǔ)法: 案例: 3.1 全列查詢(xún) 3.2 指定列查詢(xún) 3.3 查詢(xún)字段為

    2024年03月23日
    瀏覽(24)
  • 【MySql】數(shù)據(jù)庫(kù)的增刪改查

    【MySql】數(shù)據(jù)庫(kù)的增刪改查

    本篇的主要目的:對(duì)于數(shù)據(jù)庫(kù)如何去增加刪除查詢(xún)修改 主要細(xì)節(jié)在于選項(xiàng)問(wèn)題,編碼選項(xiàng) 說(shuō)明: 大寫(xiě)的表示 [] 是可選項(xiàng) CHARACTER SET: 指定數(shù)據(jù)庫(kù)采用的字符集 COLLATE: 指定數(shù)據(jù)庫(kù)字符集的校驗(yàn)規(guī)則 查看當(dāng)前用戶(hù)數(shù)據(jù)庫(kù)的列表show databases; 創(chuàng)建數(shù)據(jù)庫(kù)create database db_name; 當(dāng)

    2024年02月12日
    瀏覽(18)
  • MySQL數(shù)據(jù)庫(kù)基礎(chǔ)表格——增刪改查(上)

    MySQL數(shù)據(jù)庫(kù)基礎(chǔ)表格——增刪改查(上)

    ?? 作者:小劉在C站 ?? 個(gè)人主頁(yè): 小劉主頁(yè) ?? 每天分享云計(jì)算網(wǎng)絡(luò)運(yùn)維課堂筆記,努力不一定有回報(bào),但一定會(huì)有收獲加油!一起努力,共赴美好人生! ?? 樹(shù)高千尺,落葉歸根人生不易,人間真情 前言 不要太在乎別人對(duì)你的評(píng)價(jià),做好自己個(gè)人,干好自己的事,走

    2024年02月05日
    瀏覽(24)
  • MySQL數(shù)據(jù)庫(kù),表的增刪改查詳細(xì)講解

    MySQL數(shù)據(jù)庫(kù),表的增刪改查詳細(xì)講解

    目錄 1.CRUD 2.增加數(shù)據(jù) 2.1創(chuàng)建數(shù)據(jù) 2.2插入數(shù)據(jù) 2.2.1單行插入 2.2.2多行插入 3.查找數(shù)據(jù) 3.1全列查詢(xún) 3.2指定列查詢(xún) 3.3查詢(xún)字段為表達(dá)式 3.3.1表達(dá)式不包含字段 3.3.2表達(dá)式包含一個(gè)字段 3.3.3表達(dá)式包含多個(gè)字段? 3.4起別名 3.5distinct(去重) 3.6order by(排序) 3.6.1某字段默認(rèn)排序 3.6.2某字

    2023年04月14日
    瀏覽(25)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包