Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] PDO Delete, jw
miras
post
Post #1





Grupa: Zarejestrowani
Postów: 1 004
Pomógł: 9
Dołączył: 18.01.2011
Skąd: Siedlce

Ostrzeżenie: (30%)
XX---


Witam, mam funkcję, która ma usuwać z bazy pewien rekord.. niestety nie usuwa - co jest nie tak?

  1. public function delete_id($id,$type) {
  2. if ($type=="facebook") {
  3. $this->del = $this->pdo->exec("DELETE FROM `facebook` WHERE `id` = '{$id}'");
  4. } else if ($type=="tv") {
  5. $this->del = $this->pdo->exec("DELETE FROM tv_paczka` WHERE `id` = '{$id}'");
  6. } else if ($type=="galeria") {
  7. $this->del = $this->pdo->exec("DELETE FROM `gallery` WHERE `id` = '{$id}'");
  8. }
  9. if ($this->del) {
  10. header("Location: index.php?page=delete&type=".$type);
  11. }
  12. }
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Turson
post
Post #2





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


  1. public function delete_id($id,$type){
  2. if ($type==="facebook") {
  3. $this->type = "facebook";
  4. }
  5. elseif ($type==="tv") {
  6. $this->type = "tv_paczka";
  7. }
  8. elseif ($type==="galeria") {
  9. $this->type = "gallery";
  10. }
  11. $delete = $this->type;
  12. $stmt = $this->pdo->exec("DELETE FROM ".$delete." WHERE `id` = ".$id."");
  13. if ($stmt) {
  14. return true;
  15. }
  16. }


  1. if($obiekt->delete_id($id,$type)){
  2. header("Location: index.php?page=delete&type=".$type);
  3. }


To jest metoda a nie funkcja.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 15.10.2025 - 23:13