Parcourir la source

Update additional occurances of PDO::PGSQL_ATTR_DISABLE_PREPARES

FusionPBX il y a 3 ans
Parent
commit
68d3bcf80b
1 fichiers modifiés avec 46 ajouts et 7 suppressions
  1. 46 7
      resources/classes/database.php

+ 46 - 7
resources/classes/database.php

@@ -607,8 +607,14 @@ include "root.php";
 					$sql .= ")\n";
 					$sql .= ")\n";
 
 
 				//execute the query, show exceptions
 				//execute the query, show exceptions
-					$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION, PDO::PGSQL_ATTR_DISABLE_PREPARES);
-				
+					$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+				//reduce prepared statement latency
+					if (defined('PDO::PGSQL_ATTR_DISABLE_PREPARES')) {
+						$this->db->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES);
+					}
+
+				//prepare the sql and parameters and then execute the query
 					try {
 					try {
 						//$this->sql = $sql;
 						//$this->sql = $sql;
 						//$this->db->exec($sql);
 						//$this->db->exec($sql);
@@ -1137,7 +1143,7 @@ include "root.php";
 						$this->db->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES);
 						$this->db->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES);
 					}
 					}
 
 
-				//execute the query, and return the results
+				//execute the query and return the results
 					try {
 					try {
 						$prep_statement = $this->db->prepare($sql);
 						$prep_statement = $this->db->prepare($sql);
 						if (is_array($parameters)) {
 						if (is_array($parameters)) {
@@ -1817,8 +1823,15 @@ include "root.php";
 											$sql .= ");";
 											$sql .= ");";
 											$sql = str_replace(", )", ")", $sql);
 											$sql = str_replace(", )", ")", $sql);
 
 
-											$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION, PDO::PGSQL_ATTR_DISABLE_PREPARES);
+											//set the error mode
+											$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
 
+											//reduce prepared statement latency
+											if (defined('PDO::PGSQL_ATTR_DISABLE_PREPARES')) {
+												$this->db->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES);
+											}
+
+											//execute the query and return the results
 											try {
 											try {
 												//$this->db->query(check_sql($sql));
 												//$this->db->query(check_sql($sql));
 												$prep_statement = $this->db->prepare($sql);
 												$prep_statement = $this->db->prepare($sql);
@@ -1904,7 +1917,16 @@ include "root.php";
 											}
 											}
 											$sql .= "WHERE ".$parent_key_name." = '".$parent_key_value."' ";
 											$sql .= "WHERE ".$parent_key_name." = '".$parent_key_value."' ";
 											$sql = str_replace(", WHERE", " WHERE", $sql);
 											$sql = str_replace(", WHERE", " WHERE", $sql);
-											$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION, PDO::PGSQL_ATTR_DISABLE_PREPARES);
+
+											//set the error mode
+											$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+											//reduce prepared statement latency
+											if (defined('PDO::PGSQL_ATTR_DISABLE_PREPARES')) {
+												$this->db->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES);
+											}
+
+											//execute the query and return the results
 											try {
 											try {
 												$prep_statement = $this->db->prepare($sql);
 												$prep_statement = $this->db->prepare($sql);
 												$prep_statement->execute($params);
 												$prep_statement->execute($params);
@@ -2065,7 +2087,15 @@ include "root.php";
 																$sql .= "WHERE ".$parent_key_name." = '".$parent_key_value."' ";
 																$sql .= "WHERE ".$parent_key_name." = '".$parent_key_value."' ";
 																$sql .= "AND ".$child_key_name." = '".$child_key_value."' ";
 																$sql .= "AND ".$child_key_name." = '".$child_key_value."' ";
 																$sql = str_replace(", WHERE", " WHERE", $sql);
 																$sql = str_replace(", WHERE", " WHERE", $sql);
-																$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION, PDO::PGSQL_ATTR_DISABLE_PREPARES);
+
+																//set the error mode
+																$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+																//reduce prepared statement latency
+																if (defined('PDO::PGSQL_ATTR_DISABLE_PREPARES')) {
+																	$this->db->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES);
+																}
+
 																//$prep_statement->bindParam(':domain_uuid', $this->domain_uuid );
 																//$prep_statement->bindParam(':domain_uuid', $this->domain_uuid );
 																try {
 																try {
 																	//$this->db->query(check_sql($sql));
 																	//$this->db->query(check_sql($sql));
@@ -2189,7 +2219,16 @@ include "root.php";
 															}
 															}
 															$sql .= ");";
 															$sql .= ");";
 															$sql = str_replace(", )", ")", $sql);
 															$sql = str_replace(", )", ")", $sql);
-															$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION, PDO::PGSQL_ATTR_DISABLE_PREPARES);
+
+															//set the error mode
+															$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+															//reduce prepared statement latency
+															if (defined('PDO::PGSQL_ATTR_DISABLE_PREPARES')) {
+																$this->db->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES);
+															}
+
+															//execute the query and return the results
 															try {
 															try {
 																$prep_statement = $this->db->prepare($sql);
 																$prep_statement = $this->db->prepare($sql);
 																$prep_statement->execute($params);
 																$prep_statement->execute($params);