Explorar o código

Update database.php

Changes for database -> delete() keeping for the moment for backwards compatibility.
FusionPBX %!s(int64=8) %!d(string=hai) anos
pai
achega
2bef4f257b
Modificáronse 1 ficheiros con 21 adicións e 17 borrados
  1. 21 17
      resources/classes/database.php

+ 21 - 17
resources/classes/database.php

@@ -17,7 +17,7 @@
 
 	The Initial Developer of the Original Code is
 	Mark J Crane <[email protected]>
-	Copyright (C) 2010 - 2015
+	Copyright (C) 2010 - 2016
 	All Rights Reserved.
 
 	Contributor(s):
@@ -473,30 +473,34 @@ include "root.php";
 					unset($sql);
 			}
 
-			public function delete(){
+			public function delete() {
 				//connect to the database if needed
 					if (!$this->db) {
 						$this->connect();
 					}
+
 				//delete from the database
-					$sql = "delete from ".$this->table." ";
-					if ($this->where) {
-						$i = 0;
-						foreach($this->where as $row) {
-							if ($i == 0) {
-								$sql .= "where ".$row['name']." ".$row['operator']." '".$row['value']."' ";
-							}
-							else {
-								$sql .= "and ".$row['name']." ".$row['operator']." '".$row['value']."' ";
+					if (isset($this->table) && isset($this->where)) {
+						$sql = "delete from ".$this->table." ";
+						if ($this->where) {
+							$i = 0;
+							foreach($this->where as $row) {
+								if ($i == 0) {
+									$sql .= "where ".$row['name']." ".$row['operator']." '".$row['value']."' ";
+								}
+								else {
+									$sql .= "and ".$row['name']." ".$row['operator']." '".$row['value']."' ";
+								}
+								$i++;
 							}
-							$i++;
 						}
+						//echo $sql."<br>\n";
+						$prep_statement = $this->db->prepare($sql);
+						$prep_statement->execute();
+						unset($sql);
+						unset($this->where);
+						return;
 					}
-					//echo $sql."<br>\n";
-					$prep_statement = $this->db->prepare($sql);
-					$prep_statement->execute();
-					unset($sql);
-					unset($this->where);
 			}
 
 			public function count() {