@@ -298,8 +298,8 @@ |
||
| 298 | 298 | { |
| 299 | 299 | foreach ($options as $option => $value) |
| 300 | 300 | { |
| 301 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
| 302 | - $this->{'set'.$option}($value); |
|
| 301 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set' . $option)) |
|
| 302 | + $this->{'set' . $option}($value); |
|
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | |
@@ -216,8 +216,9 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function getArrayResult() |
| 218 | 218 | { |
| 219 | - if (!empty($this->arrayResult)) |
|
| 220 | - return $this->arrayResult; |
|
| 219 | + if (!empty($this->arrayResult)) { |
|
| 220 | + return $this->arrayResult; |
|
| 221 | + } |
|
| 221 | 222 | |
| 222 | 223 | return $this->toArray(); |
| 223 | 224 | } |
@@ -313,8 +314,9 @@ discard block |
||
| 313 | 314 | */ |
| 314 | 315 | public function autocommit($value) |
| 315 | 316 | { |
| 316 | - if ($this->transac_mode) |
|
| 317 | - throw new \LogicException("You cannot change autocommit behavior during a transaction"); |
|
| 317 | + if ($this->transac_mode) { |
|
| 318 | + throw new \LogicException("You cannot change autocommit behavior during a transaction"); |
|
| 319 | + } |
|
| 318 | 320 | |
| 319 | 321 | $this->autocommit = $value; |
| 320 | 322 | } |
@@ -330,8 +332,9 @@ discard block |
||
| 330 | 332 | { |
| 331 | 333 | foreach ($options as $option => $value) |
| 332 | 334 | { |
| 333 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
| 334 | - $this->{'set'.$option}($value); |
|
| 335 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) { |
|
| 336 | + $this->{'set'.$option}($value); |
|
| 337 | + } |
|
| 335 | 338 | } |
| 336 | 339 | } |
| 337 | 340 | |
@@ -375,8 +378,9 @@ discard block |
||
| 375 | 378 | */ |
| 376 | 379 | public function reconnect() |
| 377 | 380 | { |
| 378 | - if (!$this->isConnected()) |
|
| 379 | - throw new \LogicException("Connection was not established"); |
|
| 381 | + if (!$this->isConnected()) { |
|
| 382 | + throw new \LogicException("Connection was not established"); |
|
| 383 | + } |
|
| 380 | 384 | |
| 381 | 385 | $this->disconnect(); |
| 382 | 386 | return $this->connect(); |
@@ -405,8 +409,9 @@ discard block |
||
| 405 | 409 | */ |
| 406 | 410 | public function disconnect() |
| 407 | 411 | { |
| 408 | - if (!$this->isConnected()) |
|
| 409 | - throw new \LogicException("Connection was not established"); |
|
| 412 | + if (!$this->isConnected()) { |
|
| 413 | + throw new \LogicException("Connection was not established"); |
|
| 414 | + } |
|
| 410 | 415 | } |
| 411 | 416 | |
| 412 | 417 | /** |
@@ -418,11 +423,13 @@ discard block |
||
| 418 | 423 | */ |
| 419 | 424 | public function beginTransaction() |
| 420 | 425 | { |
| 421 | - if (!$this->isConnected()) |
|
| 422 | - $this->connect(); |
|
| 426 | + if (!$this->isConnected()) { |
|
| 427 | + $this->connect(); |
|
| 428 | + } |
|
| 423 | 429 | |
| 424 | - if ($this->transac_mode) |
|
| 425 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_STARTED]); |
|
| 430 | + if ($this->transac_mode) { |
|
| 431 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_STARTED]); |
|
| 432 | + } |
|
| 426 | 433 | |
| 427 | 434 | $this->transac_mode = true; |
| 428 | 435 | } |
@@ -436,16 +443,19 @@ discard block |
||
| 436 | 443 | */ |
| 437 | 444 | public function endTransaction() |
| 438 | 445 | { |
| 439 | - if (!$this->transac_mode) |
|
| 440 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_NOT_STARTED]); |
|
| 446 | + if (!$this->transac_mode) { |
|
| 447 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_NOT_STARTED]); |
|
| 448 | + } |
|
| 441 | 449 | |
| 442 | - if (is_null($this->transac_result)) |
|
| 443 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_EMPTY]); |
|
| 450 | + if (is_null($this->transac_result)) { |
|
| 451 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_EMPTY]); |
|
| 452 | + } |
|
| 444 | 453 | |
| 445 | - if ($this->transac_result) |
|
| 446 | - $this->commit(); |
|
| 447 | - else |
|
| 448 | - $this->rollback(); |
|
| 454 | + if ($this->transac_result) { |
|
| 455 | + $this->commit(); |
|
| 456 | + } else { |
|
| 457 | + $this->rollback(); |
|
| 458 | + } |
|
| 449 | 459 | |
| 450 | 460 | $this->result = $this->transac_result; |
| 451 | 461 | |
@@ -77,8 +77,9 @@ |
||
| 77 | 77 | |
| 78 | 78 | foreach ($arguments as $key => $arg) |
| 79 | 79 | { |
| 80 | - if (is_string($arg)) |
|
| 81 | - $arguments[$key] = "'$arg'"; |
|
| 80 | + if (is_string($arg)) { |
|
| 81 | + $arguments[$key] = "'$arg'"; |
|
| 82 | + } |
|
| 82 | 83 | } |
| 83 | 84 | |
| 84 | 85 | $arguments = implode(", ", array_values($arguments)); |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @param array $where |
| 24 | 24 | */ |
| 25 | - public function select(Array $where); |
|
| 25 | + public function select(Array $where); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Insert statement |
| 29 | 29 | * |
| 30 | 30 | * @param array $data |
| 31 | 31 | */ |
| 32 | - public function insert(Array $data); |
|
| 32 | + public function insert(Array $data); |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Update statement |
@@ -37,12 +37,12 @@ discard block |
||
| 37 | 37 | * @param array $set |
| 38 | 38 | * @param array $where |
| 39 | 39 | */ |
| 40 | - public function update(Array $set, Array $where); |
|
| 40 | + public function update(Array $set, Array $where); |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Delete statement |
| 44 | 44 | * |
| 45 | 45 | * @param array $where |
| 46 | 46 | */ |
| 47 | - public function delete(Array $where); |
|
| 47 | + public function delete(Array $where); |
|
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |
@@ -58,8 +58,9 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $result = $this->tableGateway->select($where); |
| 60 | 60 | |
| 61 | - if (!count($result)) |
|
| 62 | - return $result; |
|
| 61 | + if (!count($result)) { |
|
| 62 | + return $result; |
|
| 63 | + } |
|
| 63 | 64 | |
| 64 | 65 | $array_result = []; |
| 65 | 66 | |
@@ -69,8 +70,9 @@ discard block |
||
| 69 | 70 | |
| 70 | 71 | foreach ($row as $key => $value) |
| 71 | 72 | { |
| 72 | - if (is_string($key)) |
|
| 73 | - $filtered_array[$key] = $value; |
|
| 73 | + if (is_string($key)) { |
|
| 74 | + $filtered_array[$key] = $value; |
|
| 75 | + } |
|
| 74 | 76 | } |
| 75 | 77 | |
| 76 | 78 | $user_entity = get_class($this->tableGateway->getEntity()); |
@@ -94,10 +96,11 @@ discard block |
||
| 94 | 96 | */ |
| 95 | 97 | public function insert($entity) |
| 96 | 98 | { |
| 97 | - if ($entity instanceof Entity) |
|
| 98 | - $entity = get_object_vars($entity); |
|
| 99 | - else if (!is_array($entity)) |
|
| 100 | - throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
| 99 | + if ($entity instanceof Entity) { |
|
| 100 | + $entity = get_object_vars($entity); |
|
| 101 | + } else if (!is_array($entity)) { |
|
| 102 | + throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
| 103 | + } |
|
| 101 | 104 | |
| 102 | 105 | $this->parseEntity($entity); |
| 103 | 106 | |
@@ -126,14 +129,15 @@ discard block |
||
| 126 | 129 | |
| 127 | 130 | foreach ($entity as $key => $value) |
| 128 | 131 | { |
| 129 | - if (in_array($key, $changedFields)) |
|
| 130 | - $fieldsToModify[$key] = $value; |
|
| 132 | + if (in_array($key, $changedFields)) { |
|
| 133 | + $fieldsToModify[$key] = $value; |
|
| 134 | + } |
|
| 131 | 135 | } |
| 132 | 136 | |
| 133 | 137 | $entity = $fieldsToModify; |
| 138 | + } else if (!is_array($entity)) { |
|
| 139 | + throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
| 134 | 140 | } |
| 135 | - else if (!is_array($entity)) |
|
| 136 | - throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
| 137 | 141 | |
| 138 | 142 | $this->parseEntity($entity); |
| 139 | 143 | |
@@ -152,10 +156,11 @@ discard block |
||
| 152 | 156 | */ |
| 153 | 157 | public function delete($entity) |
| 154 | 158 | { |
| 155 | - if ($entity instanceof Entity) |
|
| 156 | - $entity = get_object_vars($entity); |
|
| 157 | - else if (!is_array($entity)) |
|
| 158 | - throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
| 159 | + if ($entity instanceof Entity) { |
|
| 160 | + $entity = get_object_vars($entity); |
|
| 161 | + } else if (!is_array($entity)) { |
|
| 162 | + throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
| 163 | + } |
|
| 159 | 164 | |
| 160 | 165 | return $this->tableGateway->delete($entity); |
| 161 | 166 | } |
@@ -108,8 +108,8 @@ |
||
| 108 | 108 | { |
| 109 | 109 | foreach ($options as $option => $value) |
| 110 | 110 | { |
| 111 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
| 112 | - $this->{'set'.$option}($value); |
|
| 111 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set' . $option)) |
|
| 112 | + $this->{'set' . $option}($value); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | if (!($socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) |
@@ -108,8 +108,9 @@ |
||
| 108 | 108 | { |
| 109 | 109 | foreach ($options as $option => $value) |
| 110 | 110 | { |
| 111 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
| 112 | - $this->{'set'.$option}($value); |
|
| 111 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) { |
|
| 112 | + $this->{'set'.$option}($value); |
|
| 113 | + } |
|
| 113 | 114 | } |
| 114 | 115 | |
| 115 | 116 | if (!($socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) |
@@ -107,11 +107,12 @@ |
||
| 107 | 107 | { |
| 108 | 108 | $this->$prop = $value; |
| 109 | 109 | |
| 110 | - if (!in_array($prop, $this->changedFields)) |
|
| 111 | - $this->changedFields[] = $prop; |
|
| 110 | + if (!in_array($prop, $this->changedFields)) { |
|
| 111 | + $this->changedFields[] = $prop; |
|
| 112 | + } |
|
| 113 | + } else { |
|
| 114 | + throw new \LogicException("The property '$prop' does not exists in the class ' " . get_class($this) . " '"); |
|
| 112 | 115 | } |
| 113 | - else |
|
| 114 | - throw new \LogicException("The property '$prop' does not exists in the class ' " . get_class($this) . " '"); |
|
| 115 | 116 | } |
| 116 | 117 | } |
| 117 | 118 | |
@@ -59,10 +59,10 @@ discard block |
||
| 59 | 59 | ? $this->dbname |
| 60 | 60 | : |
| 61 | 61 | (!is_null($this->dbport) && !empty($this->dbport)) |
| 62 | - ? $this->dbhost .":". $this->dbport ."/". $this->dbname |
|
| 63 | - : $this->dbhost ."/". $this->dbname; |
|
| 62 | + ? $this->dbhost . ":" . $this->dbport . "/" . $this->dbname |
|
| 63 | + : $this->dbhost . "/" . $this->dbname; |
|
| 64 | 64 | |
| 65 | - $conn = @oci_connect($this->dbuser, $this->dbpass, $connection_string, $this->dbchar); |
|
| 65 | + $conn = @oci_connect($this->dbuser, $this->dbpass, $connection_string, $this->dbchar); |
|
| 66 | 66 | |
| 67 | 67 | if ($conn === false) |
| 68 | 68 | { |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $prev_error_handler = set_error_handler(['\Drone\Error\ErrorHandler', 'errorControlOperator'], E_ALL); |
| 132 | 132 | |
| 133 | 133 | // may be throw a Fatal error (Ex: Maximum execution time) |
| 134 | - $r = ($this->transac_mode) ? oci_execute($stid, OCI_NO_AUTO_COMMIT) : oci_execute($stid, OCI_COMMIT_ON_SUCCESS); |
|
| 134 | + $r = ($this->transac_mode) ? oci_execute($stid, OCI_NO_AUTO_COMMIT) : oci_execute($stid, OCI_COMMIT_ON_SUCCESS); |
|
| 135 | 135 | |
| 136 | 136 | set_error_handler($prev_error_handler); |
| 137 | 137 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $this->numFields = oci_num_fields($stid); |
| 153 | 153 | |
| 154 | 154 | if ($this->transac_mode) |
| 155 | - $this->transac_result = is_null($this->transac_result) ? $stid: $this->transac_result && $stid; |
|
| 155 | + $this->transac_result = is_null($this->transac_result) ? $stid : $this->transac_result && $stid; |
|
| 156 | 156 | |
| 157 | 157 | $this->result = $stid; |
| 158 | 158 | |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | if ($this->result) |
| 199 | 199 | { |
| 200 | - while ( ($row = @oci_fetch_array($this->result, OCI_BOTH + OCI_RETURN_NULLS)) !== false ) |
|
| 200 | + while (($row = @oci_fetch_array($this->result, OCI_BOTH + OCI_RETURN_NULLS)) !== false) |
|
| 201 | 201 | { |
| 202 | 202 | $data[] = $row; |
| 203 | 203 | } |
@@ -33,15 +33,17 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $this->driverName = 'Oci8'; |
| 35 | 35 | |
| 36 | - if (!array_key_exists("dbchar", $options)) |
|
| 37 | - $options["dbchar"] = "AL32UTF8"; |
|
| 36 | + if (!array_key_exists("dbchar", $options)) { |
|
| 37 | + $options["dbchar"] = "AL32UTF8"; |
|
| 38 | + } |
|
| 38 | 39 | |
| 39 | 40 | parent::__construct($options); |
| 40 | 41 | |
| 41 | 42 | $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true; |
| 42 | 43 | |
| 43 | - if ($auto_connect) |
|
| 44 | - $this->connect(); |
|
| 44 | + if ($auto_connect) { |
|
| 45 | + $this->connect(); |
|
| 46 | + } |
|
| 45 | 47 | } |
| 46 | 48 | |
| 47 | 49 | /** |
@@ -54,8 +56,9 @@ discard block |
||
| 54 | 56 | */ |
| 55 | 57 | public function connect() |
| 56 | 58 | { |
| 57 | - if (!extension_loaded('oci8')) |
|
| 58 | - throw new \RuntimeException("The Oci8 extension is not loaded"); |
|
| 59 | + if (!extension_loaded('oci8')) { |
|
| 60 | + throw new \RuntimeException("The Oci8 extension is not loaded"); |
|
| 61 | + } |
|
| 59 | 62 | |
| 60 | 63 | $connection_string = (is_null($this->dbhost) || empty($this->dbhost)) |
| 61 | 64 | ? $this->dbname |
@@ -108,14 +111,15 @@ discard block |
||
| 108 | 111 | ]; |
| 109 | 112 | |
| 110 | 113 | $this->error($error["message"]); |
| 114 | + } else { |
|
| 115 | + $this->error($error["code"], $error["message"]); |
|
| 111 | 116 | } |
| 112 | - else |
|
| 113 | - $this->error($error["code"], $error["message"]); |
|
| 114 | 117 | |
| 115 | - if (array_key_exists("code", $error)) |
|
| 116 | - throw new Exception\InvalidQueryException($error["message"], $error["code"]); |
|
| 117 | - else |
|
| 118 | - throw new Exception\InvalidQueryException($error["message"]); |
|
| 118 | + if (array_key_exists("code", $error)) { |
|
| 119 | + throw new Exception\InvalidQueryException($error["message"], $error["code"]); |
|
| 120 | + } else { |
|
| 121 | + throw new Exception\InvalidQueryException($error["message"]); |
|
| 122 | + } |
|
| 119 | 123 | } |
| 120 | 124 | |
| 121 | 125 | # Bound variables |
@@ -155,8 +159,9 @@ discard block |
||
| 155 | 159 | $this->numRows = count($rows); |
| 156 | 160 | $this->numFields = oci_num_fields($stid); |
| 157 | 161 | |
| 158 | - if ($this->transac_mode) |
|
| 159 | - $this->transac_result = is_null($this->transac_result) ? $stid: $this->transac_result && $stid; |
|
| 162 | + if ($this->transac_mode) { |
|
| 163 | + $this->transac_result = is_null($this->transac_result) ? $stid: $this->transac_result && $stid; |
|
| 164 | + } |
|
| 160 | 165 | |
| 161 | 166 | $this->result = $stid; |
| 162 | 167 | |
@@ -205,10 +210,10 @@ discard block |
||
| 205 | 210 | { |
| 206 | 211 | $data[] = $row; |
| 207 | 212 | } |
| 208 | - } |
|
| 209 | - else |
|
| 210 | - # This error is thrown because of 'execute' method has not been executed. |
|
| 213 | + } else { |
|
| 214 | + # This error is thrown because of 'execute' method has not been executed. |
|
| 211 | 215 | throw new \LogicException('There are not data in the buffer!'); |
| 216 | + } |
|
| 212 | 217 | |
| 213 | 218 | $this->arrayResult = $data; |
| 214 | 219 | |
@@ -222,7 +227,8 @@ discard block |
||
| 222 | 227 | */ |
| 223 | 228 | public function __destruct() |
| 224 | 229 | { |
| 225 | - if ($this->dbconn) |
|
| 226 | - oci_close($this->dbconn); |
|
| 230 | + if ($this->dbconn) { |
|
| 231 | + oci_close($this->dbconn); |
|
| 232 | + } |
|
| 227 | 233 | } |
| 228 | 234 | } |
| 229 | 235 | \ No newline at end of file |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | else |
| 133 | 133 | { |
| 134 | 134 | if ($isSelectStm) |
| 135 | - $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET )); |
|
| 135 | + $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array("Scrollable" => SQLSRV_CURSOR_KEYSET)); |
|
| 136 | 136 | else |
| 137 | 137 | $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params); |
| 138 | 138 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | $this->rowsAffected = sqlsrv_rows_affected($this->result); |
| 159 | 159 | |
| 160 | 160 | if ($this->transac_mode) |
| 161 | - $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
| 161 | + $this->transac_result = is_null($this->transac_result) ? $this->result : $this->transac_result && $this->result; |
|
| 162 | 162 | |
| 163 | 163 | return $this->result; |
| 164 | 164 | } |
@@ -33,15 +33,17 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $this->driverName = 'Sqlsrv'; |
| 35 | 35 | |
| 36 | - if (!array_key_exists("dbchar", $options)) |
|
| 37 | - $options["dbchar"] = "UTF-8"; |
|
| 36 | + if (!array_key_exists("dbchar", $options)) { |
|
| 37 | + $options["dbchar"] = "UTF-8"; |
|
| 38 | + } |
|
| 38 | 39 | |
| 39 | 40 | parent::__construct($options); |
| 40 | 41 | |
| 41 | 42 | $auto_connect = array_key_exists('auto_connect', $options) ? $options["auto_connect"] : true; |
| 42 | 43 | |
| 43 | - if ($auto_connect) |
|
| 44 | - $this->connect(); |
|
| 44 | + if ($auto_connect) { |
|
| 45 | + $this->connect(); |
|
| 46 | + } |
|
| 45 | 47 | } |
| 46 | 48 | |
| 47 | 49 | /** |
@@ -54,11 +56,13 @@ discard block |
||
| 54 | 56 | */ |
| 55 | 57 | public function connect() |
| 56 | 58 | { |
| 57 | - if (!extension_loaded('sqlsrv')) |
|
| 58 | - throw new \RuntimeException("The Sqlsrv extension is not loaded"); |
|
| 59 | + if (!extension_loaded('sqlsrv')) { |
|
| 60 | + throw new \RuntimeException("The Sqlsrv extension is not loaded"); |
|
| 61 | + } |
|
| 59 | 62 | |
| 60 | - if (!is_null($this->dbport) && !empty($this->dbport)) |
|
| 61 | - $this->dbhost .= ', ' . $this->dbport; |
|
| 63 | + if (!is_null($this->dbport) && !empty($this->dbport)) { |
|
| 64 | + $this->dbhost .= ', ' . $this->dbport; |
|
| 65 | + } |
|
| 62 | 66 | |
| 63 | 67 | $db_info = array("Database" => $this->dbname, "UID" => $this->dbuser, "PWD" => $this->dbpass, "CharacterSet" => $this->dbchar); |
| 64 | 68 | $conn = sqlsrv_connect($this->dbhost, $db_info); |
@@ -139,13 +143,13 @@ discard block |
||
| 139 | 143 | } |
| 140 | 144 | |
| 141 | 145 | $exec = sqlsrv_execute($stmt); |
| 142 | - } |
|
| 143 | - else |
|
| 146 | + } else |
|
| 144 | 147 | { |
| 145 | - if ($isSelectStm) |
|
| 146 | - $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET )); |
|
| 147 | - else |
|
| 148 | - $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params); |
|
| 148 | + if ($isSelectStm) { |
|
| 149 | + $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET )); |
|
| 150 | + } else { |
|
| 151 | + $exec = $this->result = sqlsrv_query($this->dbconn, $sql, $params); |
|
| 152 | + } |
|
| 149 | 153 | } |
| 150 | 154 | |
| 151 | 155 | if ($exec === false) |
@@ -165,11 +169,13 @@ discard block |
||
| 165 | 169 | $this->numRows = sqlsrv_has_rows($this->result) ? sqlsrv_num_rows($this->result) : $this->numRows; |
| 166 | 170 | $this->numFields = sqlsrv_num_fields($this->result); |
| 167 | 171 | |
| 168 | - if ($isInsertStm || $isUpdateStm || $isDeleteStm) |
|
| 169 | - $this->rowsAffected = sqlsrv_rows_affected($this->result); |
|
| 172 | + if ($isInsertStm || $isUpdateStm || $isDeleteStm) { |
|
| 173 | + $this->rowsAffected = sqlsrv_rows_affected($this->result); |
|
| 174 | + } |
|
| 170 | 175 | |
| 171 | - if ($this->transac_mode) |
|
| 172 | - $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
| 176 | + if ($this->transac_mode) { |
|
| 177 | + $this->transac_result = is_null($this->transac_result) ? $this->result: $this->transac_result && $this->result; |
|
| 178 | + } |
|
| 173 | 179 | |
| 174 | 180 | return $this->result; |
| 175 | 181 | } |
@@ -236,10 +242,10 @@ discard block |
||
| 236 | 242 | { |
| 237 | 243 | $data[] = $row; |
| 238 | 244 | } |
| 239 | - } |
|
| 240 | - else |
|
| 241 | - # This error is thrown because of 'execute' method has not been executed. |
|
| 245 | + } else { |
|
| 246 | + # This error is thrown because of 'execute' method has not been executed. |
|
| 242 | 247 | throw new \LogicException('There are not data in the buffer!'); |
| 248 | + } |
|
| 243 | 249 | |
| 244 | 250 | $this->arrayResult = $data; |
| 245 | 251 | |
@@ -253,7 +259,8 @@ discard block |
||
| 253 | 259 | */ |
| 254 | 260 | public function __destruct() |
| 255 | 261 | { |
| 256 | - if ($this->dbconn) |
|
| 257 | - sqlsrv_close($this->dbconn); |
|
| 262 | + if ($this->dbconn) { |
|
| 263 | + sqlsrv_close($this->dbconn); |
|
| 264 | + } |
|
| 258 | 265 | } |
| 259 | 266 | } |
| 260 | 267 | \ No newline at end of file |
@@ -141,13 +141,11 @@ |
||
| 141 | 141 | try |
| 142 | 142 | { |
| 143 | 143 | $shell->cp('foo2', 'foo3'); |
| 144 | - } |
|
| 145 | - catch (\Exception $e) |
|
| 144 | + } catch (\Exception $e) |
|
| 146 | 145 | { |
| 147 | 146 | # omitting directory |
| 148 | 147 | $errorObject = ($e instanceof \RuntimeException); |
| 149 | - } |
|
| 150 | - finally |
|
| 148 | + } finally |
|
| 151 | 149 | { |
| 152 | 150 | $this->assertTrue($errorObject, $e->getMessage()); |
| 153 | 151 | } |
@@ -194,7 +194,7 @@ |
||
| 194 | 194 | $this->assertTrue(is_dir('foo4/foo2')); |
| 195 | 195 | $this->assertTrue(file_exists('foo4/foo2/new3.txt')); |
| 196 | 196 | $this->assertTrue(file_exists('foo4/foo2/new4.txt')); |
| 197 | - } |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | 199 | /** |
| 200 | 200 | * Tests removing files |