Maurits van der Schee 8 years ago
parent
commit
e3dd93f0f3
1 changed files with 4 additions and 3 deletions
  1. 4
    3
      api.php

+ 4
- 3
api.php View File

@@ -94,6 +94,10 @@ class MySQL implements DatabaseInterface {
94 94
 
95 95
 	public function connect($hostname,$username,$password,$database,$port,$socket,$charset) {
96 96
 		$db = mysqli_init();
97
+		$option = constant('MYSQLI_OPT_INT_AND_FLOAT_NATIVE');
98
+		if ($option!==null && !mysqli_options($db,$option,true)) {
99
+			throw new \Exception('Error setting int and float native. '.mysqli_error($db));
100
+		}
97 101
 		$success = mysqli_real_connect($db,$hostname,$username,$password,$database,$port,$socket,MYSQLI_CLIENT_FOUND_ROWS);
98 102
 		if (!$success) {
99 103
 			throw new \Exception('Connect failed. '.mysqli_connect_error());
@@ -104,9 +108,6 @@ class MySQL implements DatabaseInterface {
104 108
 		if (!mysqli_query($db,'SET SESSION sql_mode = \'ANSI_QUOTES\';')) {
105 109
 			throw new \Exception('Error setting ANSI quotes. '.mysqli_error($db));
106 110
 		}
107
-		if (!mysqli_options($db,MYSQLI_OPT_INT_AND_FLOAT_NATIVE,true)) {
108
-			throw new \Exception('Error setting int and float native. '.mysqli_error($db));
109
-		}
110 111
 		$this->db = $db;
111 112
 	}
112 113
 

Loading…
Cancel
Save