diff --git a/resources/classes/database.php b/resources/classes/database.php index d98102528f..d240006b4b 100644 --- a/resources/classes/database.php +++ b/resources/classes/database.php @@ -607,8 +607,14 @@ include "root.php"; $sql .= ")\n"; //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 { //$this->sql = $sql; //$this->db->exec($sql); @@ -1137,7 +1143,7 @@ include "root.php"; $this->db->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES); } - //execute the query, and return the results + //execute the query and return the results try { $prep_statement = $this->db->prepare($sql); if (is_array($parameters)) { @@ -1817,8 +1823,15 @@ include "root.php"; $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 { //$this->db->query(check_sql($sql)); $prep_statement = $this->db->prepare($sql); @@ -1904,7 +1917,16 @@ include "root.php"; } $sql .= "WHERE ".$parent_key_name." = '".$parent_key_value."' "; $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 { $prep_statement = $this->db->prepare($sql); $prep_statement->execute($params); @@ -2065,7 +2087,15 @@ include "root.php"; $sql .= "WHERE ".$parent_key_name." = '".$parent_key_value."' "; $sql .= "AND ".$child_key_name." = '".$child_key_value."' "; $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 ); try { //$this->db->query(check_sql($sql)); @@ -2189,7 +2219,16 @@ include "root.php"; } $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 { $prep_statement = $this->db->prepare($sql); $prep_statement->execute($params);