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
 
94
 
95
 	public function connect($hostname,$username,$password,$database,$port,$socket,$charset) {
95
 	public function connect($hostname,$username,$password,$database,$port,$socket,$charset) {
96
 		$db = mysqli_init();
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
 		$success = mysqli_real_connect($db,$hostname,$username,$password,$database,$port,$socket,MYSQLI_CLIENT_FOUND_ROWS);
101
 		$success = mysqli_real_connect($db,$hostname,$username,$password,$database,$port,$socket,MYSQLI_CLIENT_FOUND_ROWS);
98
 		if (!$success) {
102
 		if (!$success) {
99
 			throw new \Exception('Connect failed. '.mysqli_connect_error());
103
 			throw new \Exception('Connect failed. '.mysqli_connect_error());
104
 		if (!mysqli_query($db,'SET SESSION sql_mode = \'ANSI_QUOTES\';')) {
108
 		if (!mysqli_query($db,'SET SESSION sql_mode = \'ANSI_QUOTES\';')) {
105
 			throw new \Exception('Error setting ANSI quotes. '.mysqli_error($db));
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
 		$this->db = $db;
111
 		$this->db = $db;
111
 	}
112
 	}
112
 
113
 

Loading…
Cancel
Save