1

私はphpでこのMYsql DELETE関数を書​​きました

function DeleteProduct($thisCatalog) {

    $connB = new ProductDAO();
    $connB->Connect();
    $pro_query = "DELETE * FROM Ikea WHERE `CatalogNumber` = $thisCatalog";
    $db_result = $connB->ExecSQL($pro_query);

    $html_result = 'Your Product Has Been Deleted! ';

    $connB->Disconnect();
    return $html_result;
}

これは実行中のコマンドです

DeleteProduct($CatalogNumber);
4

1 に答える 1

1

削除構文は、選択構文とは異なります (列名を選択したり、 a をまったく使用したりしません*)。

"DELETE FROM Ikea WHERE `CatalogNumber` = $thisCatalog";

トリックを行う必要があります。

そして、私のテストデータベースからのいくつかの例:

mysql> select * from first;
+------+-------+
| id   | title |
+------+-------+
|    1 | aaaa  |
|    2 | bbbb  |
|    3 | cccc  |
|    4 | NULL  |
|    6 | gggg  |
+------+-------+
5 rows in set (0.00 sec)

mysql> insert into first values (7, 'cccc');
Query OK, 1 row affected (0.01 sec)

mysql> select * from first;
+------+-------+
| id   | title |
+------+-------+
|    1 | aaaa  |
|    2 | bbbb  |
|    3 | cccc  |
|    4 | NULL  |
|    6 | gggg  |
|    7 | cccc  |
+------+-------+
6 rows in set (0.00 sec)

mysql> delete from first where id=7;
Query OK, 1 row affected (0.01 sec)

mysql> select * from first;
+------+-------+
| id   | title |
+------+-------+
|    1 | aaaa  |
|    2 | bbbb  |
|    3 | cccc  |
|    4 | NULL  |
|    6 | gggg  |
+------+-------+
5 rows in set (0.00 sec)
于 2012-09-08T14:36:44.110 に答える