crud 相关问题

数据管理系统的四个基本操作:创建,读取,更新,删除

为所有DateTimeField设置默认view_timezone

在 EasyAdmin 3 / Symfony 5.2 后端中,我有几个带有日期时间字段的 *CrudController 类,它们的配置如下: 公共函数configureFields(字符串$ pageName):可迭代 {

回答 2 投票 0

如何使用 JpaRepository 查找具有多个非必需请求参数的对象?

我需要从分页请求中找到所有 3 个非必需参数的一些对象: @GetMapping 公共 ResponseEntity> getBooks(@RequestParam(value = "名称",

回答 1 投票 0

Netbeans 创建“从实体类的 JPA 控制器类”

我想实现 JAVA 程序已有的数据库模式可用的基本 CRUD 操作。换句话说,我有一个与 PHP 一起使用的数据库模式,我只需要它们成为实体

回答 2 投票 0

尝试编辑时无法自动填写表单 - CRUD

您好,我尝试使用 Laravel CRUD 的编辑功能和资源。我遇到的问题是表单没有填充我已经使用 value="...

回答 1 投票 0

为什么我的 PHP 代码无法正确更新我的 CRUD 应用程序?

我正在尝试为我的业务制作一个CRUD应用程序,我对PHP知之甚少。我遵循了一个已被证明是成功的指南,直到我到达更新部分。 我正在尝试为我的业务制作一个 CRUD 应用程序,我对 PHP 知之甚少。我遵循了一个已被证明是成功的指南,直到我到达更新部分。 <?php $servername = "localhost"; $username = "root"; $password = ""; $database= "replog_test"; //create connection $connection = new mysqli($servername, $username, $password, $database); $id = ""; $service_dept=""; $po=""; $customer=""; $pcs=""; $equipment=""; $date_rec=""; $problem=""; $warr=""; $date_ship=""; $errorMessage = ""; $successMessage = ""; if ($_SERVER['REQUEST_METHOD'] == 'GET') { //GET method: Show the data of the client if (!isset($_GET["id"])) { header("location: /novasvm/index.php"); exit; } $id = $_GET["id"]; // read the row of the selected client from the database table $sql = "SELECT * FROM replog WHERE id=$id"; $result = $connection->query($sql); $row = $result->fetch_assoc(); if (!$row) { header("location: /novasvm/index.php"); exit; } $service_dept = $row["service_dept"]; $po = $row["po"]; $customer = $row["customer"]; $pcs = $row["pcs"]; $equipment = $row["equipment"]; $date_rec = $row["date_rec"]; $problem = $row["problem"]; $warr = $row["warr"]; $date_ship = $row["date_ship"]; } else { // POST method: Update the data of the client $service_dept = $_POST["service_dept"]; $po = $_POST["po"]; $customer = $_POST["customer"]; $pcs = $_POST["pcs"]; $equipment = $_POST["equipment"]; $date_rec = $_POST["date_rec"]; $problem = $_POST["problem"]; $warr = $_POST["warr"]; $date_ship = $_POST["date_ship"]; do { if ( empty($service_dept) || empty($po) || empty($customer) || empty($pcs) || empty($equipment) || empty($date_rec) || empty($problem) || empty($warr)) { $errorMessage = "All fields except DATE SHIPPED are required"; break; } $sql = "UPDATE replog " . "SET service_dept = '$service_dept', po = '$po', customer = '$customer', pcs = '$pcs', equipment = '$equipment', date_rec = '$date_rec', problem = '$problem', warr = '$warr', date_ship = '$date_ship' " . "WHERE id = '$id'"; $result = $connection->query($sql); if (!$result) { $errorMessage = "Invalid Query: " . $connection->error; break; } $successMessage = "Client Updated Correctly"; header("location: /novasvm/general/replog.php"); exit; } while(false); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="../style.css" type="text/css"> <link rel="stylesheet" href="../reset.css" type="text/css"> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet"> <title>Repair Log</title> </head> <body> <div> <h2>New Data</h2> <?php if ( !empty($errorMessage)) { echo " <div> <strong>$errorMessage</strong> </div> "; } ?> <form method="post"> <input type="hidden" name="id" value="<?php echo $id; ?>"> <div> <label>Service Department</label> <div> <input type="text" name="service_dept" value="<?php echo $service_dept; ?>"> </div> </div> <div> <label>PO Number</label> <div> <input type="text" name="po" value="<?php echo $po; ?>"> </div> </div> <div> <label>Customer</label> <div> <input type="text" name="customer" value="<?php echo $customer; ?>"> </div> </div> <div> <label>Pieces</label> <div> <select name="pcs" id=""> <option value="" selected="selected"></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> </select> </div> </div> <div> <label>Equipment</label> <div> <input type="text" name="equipment" value="<?php echo $equipment; ?>"> </div> </div> <div> <label>Date Received</label> <div> <input type="date" name="date_rec" value="<?php echo $date_rec; ?>"> </div> </div> <div> <label>Problem / Serial No.</label> <div> <input type="text" name="problem" value="<?php echo $problem; ?>"> </div> </div> <div> <label>Warranty</label> <div> <select name="warr" id=""> <option value="" selected="selected"></option> <option value="yes">Yes</option> <option value="no">No</option> </select> </div> </div> <div> <label>Date Shipped</label> <div> <input type="date" name="date_ship" value="<?php echo $date_ship; ?>"> </div> </div> <?php if (!empty($successMessage)) { echo " <div> <strong>$successMessage</strong> </div> "; } ?> <div> <button type="submit">Submit</button> </div> <div> <a href="/novasvm/general/replog.php" role="button">Cancel</a> </div> </form> </div> </body> </html> 一旦我提交数据,它实际上就不会在 xampp 服务器或网页上更新。它保持完全相同。 数据库信息的预期更新无法正常运行。 您没有在实际的 $id 分支中为 else 语句设置 UPDATE...。试试这样: <?php $servername = "localhost"; $username = "root"; $password = ""; $database= "replog_test"; //create connection $connection = new mysqli($servername, $username, $password, $database); $id = ""; $service_dept=""; $po=""; $customer=""; $pcs=""; $equipment=""; $date_rec=""; $problem=""; $warr=""; $date_ship=""; $errorMessage = ""; $successMessage = ""; if ($_SERVER['REQUEST_METHOD'] == 'GET') { //GET method: Show the data of the client if (!isset($_GET["id"])) { header("location: /novasvm/index.php"); exit; } $id = $_GET["id"]; // read the row of the selected client from the database table $sql = "SELECT * FROM replog WHERE id=$id"; $result = $connection->query($sql); $row = $result->fetch_assoc(); if (!$row) { header("location: /novasvm/index.php"); exit; } $service_dept = $row["service_dept"]; $po = $row["po"]; $customer = $row["customer"]; $pcs = $row["pcs"]; $equipment = $row["equipment"]; $date_rec = $row["date_rec"]; $problem = $row["problem"]; $warr = $row["warr"]; $date_ship = $row["date_ship"]; } else { // POST method: Update the data of the client $service_dept = $_POST["service_dept"]; $po = $_POST["po"]; $customer = $_POST["customer"]; $pcs = $_POST["pcs"]; $equipment = $_POST["equipment"]; $date_rec = $_POST["date_rec"]; $problem = $_POST["problem"]; $warr = $_POST["warr"]; $date_ship = $_POST["date_ship"]; $id = $_POST["id"]; // <---------- do { if ( empty($service_dept) || empty($po) || empty($customer) || empty($pcs) || empty($equipment) || empty($date_rec) || empty($problem) || empty($warr)) { $errorMessage = "All fields except DATE SHIPPED are required"; break; } $sql = "UPDATE replog " . "SET service_dept = '$service_dept', po = '$po', customer = '$customer', pcs = '$pcs', equipment = '$equipment', date_rec = '$date_rec', problem = '$problem', warr = '$warr', date_ship = '$date_ship' " . "WHERE id = '$id'"; $result = $connection->query($sql); if (!$result) { $errorMessage = "Invalid Query: " . $connection->error; break; } $successMessage = "Client Updated Correctly"; header("location: /novasvm/general/replog.php"); exit; } while(false); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="../style.css" type="text/css"> <link rel="stylesheet" href="../reset.css" type="text/css"> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet"> <title>Repair Log</title> </head> <body> <div> <h2>New Data</h2> <?php if ( !empty($errorMessage)) { echo " <div> <strong>$errorMessage</strong> </div> "; } ?> <form method="post"> <input type="hidden" name="id" value="<?php echo $id; ?>"> <div> <label>Service Department</label> <div> <input type="text" name="service_dept" value="<?php echo $service_dept; ?>"> </div> </div> <div> <label>PO Number</label> <div> <input type="text" name="po" value="<?php echo $po; ?>"> </div> </div> <div> <label>Customer</label> <div> <input type="text" name="customer" value="<?php echo $customer; ?>"> </div> </div> <div> <label>Pieces</label> <div> <select name="pcs" id=""> <option value="" selected="selected"></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> </select> </div> </div> <div> <label>Equipment</label> <div> <input type="text" name="equipment" value="<?php echo $equipment; ?>"> </div> </div> <div> <label>Date Received</label> <div> <input type="date" name="date_rec" value="<?php echo $date_rec; ?>"> </div> </div> <div> <label>Problem / Serial No.</label> <div> <input type="text" name="problem" value="<?php echo $problem; ?>"> </div> </div> <div> <label>Warranty</label> <div> <select name="warr" id=""> <option value="" selected="selected"></option> <option value="yes">Yes</option> <option value="no">No</option> </select> </div> </div> <div> <label>Date Shipped</label> <div> <input type="date" name="date_ship" value="<?php echo $date_ship; ?>"> </div> </div> <?php if (!empty($successMessage)) { echo " <div> <strong>$successMessage</strong> </div> "; } ?> <div> <button type="submit">Submit</button> </div> <div> <a href="/novasvm/general/replog.php" role="button">Cancel</a> </div> </form> </div> </body> </html>

回答 1 投票 0

Django用ajax删除记录只有手动刷新后才消失

我想使用 Ajax 和 Sweetalert2 对话框从表中删除记录。但是,当我单击删除按钮并确认删除时,该项目将从模式中删除,但在...

回答 1 投票 0

在所有 CRUD 函数中使用“with”

FastAPI 存在一些问题(从数据库读取数据并“丢失”数据),因此我们使用 with 而不是 Depends。 这是一个好的做法吗? 使用 SessionManager() 作为数据库: @router.get("/{id}&

回答 1 投票 0

无法连接MongoDB与Node.js

我最近学习了MongoDB并将其连接到Node.js,但遇到了无法解决的错误。我正在使用 VS Code,出现了类似以下内容的弹出窗口: ”“

回答 1 投票 0

Laravel API 在 1364 字段处出现邮差一般错误

Illuminate\Database\QueryException:SQLSTATE[HY000]:一般错误: 1364 字段“user_id”没有默认值 (连接:mysql,SQL:插入帖子(post,updated_at, 创建于)值(

回答 1 投票 0

使用 WC Kalkulator 产品字段值更新 WooCommerce 购物车项目属性

在 WooCommerce 中,我将 WC Kalkulator 插件用于一个简单的产品 (ID 4692)。问题是,这个简单的产品只有静态重量和尺寸值,这些值被拉入每个购物车项目

回答 1 投票 0

使用产品自定义字段值更新 WooCommerce 购物车项目属性

在 WooCommerce 中,我将 WC Kalkulator 插件用于一个简单的产品 (ID 4692)。问题是,这个简单的产品只有静态重量和尺寸值,这些值被拉入每个购物车项目

回答 1 投票 0

如何使用 WC Kalkulator 中的字段值将唯一的运输重量、长度、宽度和高度应用于添加到 woocom 购物车的每个实例?

我已经安装了插件 WC Kalkulator 并可与我的 woocommerce 网站配合使用。它以简单的产品 ID 4692 运行。问题是,简单的产品只有静态重量和尺寸 va...

回答 1 投票 0

设置可变产品的销售价格,而不会使它们在 Woocommerce 中缺货

我有以下代码: foreach ($loop->posts as $product) { $currentPrice = get_post_meta($product->ID, '_regular_price', true); update_post_meta( $product->ID, '_price', $currentPric...

回答 1 投票 0

MongoDB CRUD Nextjs 删除请求不起作用

我正在尝试删除主题,但不起作用。我认为 id 完全为空,但仍然无法解决这个问题。 这是我的 app/api/topics/[id]/route.js 从“@/lib”导入connectMongoDB; 导入T...

回答 1 投票 0

C# 表单与 MySQL、DataGridView

有没有办法让这个C#形式的DataGridView与MySQL配合,设置更简单?在这个示例项目中,我使用 myDB 数据库人员表来填充 DataGridView,并处理 CRUD 方法...

回答 1 投票 0

laravel 背包中面临令牌不匹配错误

我面临一个问题。我使用 Laravel Backpack 制作了一个完整的管理面板。上传到域后,在添加删除或编辑操作时会产生问题。错误是令牌

回答 1 投票 0

获取分页用户列表时出错;可能出了什么问题?

我在使用 FastApi、Sqlalchemy 和 Pydantic (v2) 模式获得某些预期结果时遇到了一些麻烦。 这是我运行的代码,是为了解决这个问题而抽象的: 数据...

回答 1 投票 0

SQLAlchemy 由于 AttributeError 未更新数据库

我在一个带有flask的crm项目上有一个“编辑任务”页面,我已经构建了一个POST路由来更新数据库,然后重定向到“任务页面”。然而,我不断收到 AttributeEr...

回答 1 投票 0

如何正确处理laravel表单?

我想正确处理用户存储表单。 我认为哪种模式最正确/最流行。它是存储库模式吗?服务模式? 另一个难点: 用户表格:姓名、电子邮件、邮政编码...

回答 1 投票 0

在 Nova Action fields() 上运行 where()->get()

我试图提供一个选择列表,其中仅包含通过数据透视表与模型相关的记录。 在为客户构建时间跟踪器/预算软件时,我正在使用两个模型......

回答 5 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.