diff --git a/src/MyMssql.php b/src/MyMssql.php index f9441ad..3b8e9dc 100755 --- a/src/MyMssql.php +++ b/src/MyMssql.php @@ -197,7 +197,7 @@ public function rollback() public function fetchOne($sql) { try { - $stmt = $this->exec($sql); + $stmt = $this->query($sql); if ('SQLSRV' === $this->ini['ADAPTER']) { $result = sqlsrv_fetch_array($stmt); @@ -222,7 +222,7 @@ public function fetchOne($sql) public function fetchRow($sql) { try { - $stmt = $this->exec($sql); + $stmt = $this->query($sql); if ('SQLSRV' === $this->ini['ADAPTER']) { $result = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC); @@ -247,7 +247,7 @@ public function fetchRow($sql) public function fetchAll($sql) { try { - $stmt = $this->exec($sql); + $stmt = $this->query($sql); $result = array(); if ('SQLSRV' == $this->ini['ADAPTER']) { @@ -274,9 +274,9 @@ public function fetchAll($sql) } } - /* exec */ + /* query */ - public function exec($sql) + public function query($sql) { try { $this->connect(); @@ -292,10 +292,27 @@ public function exec($sql) } if (true == $this->ini['VERBOSE']) { - $this->logger('MyMssql Exec: '.$sql); + $this->logger('MyMssql Query: '.$sql); } return $stmt; + } catch (Exception $e) { + $err = $e->getMessage(); + $this->logger('MyMssql Query '.$this->ini['ADAPTER'], $err); + die(print_r($e->getMessage())); + } + } + + public function exec($sql) + { + try { + $stmt = $this->query($sql); + + if (true == $this->ini['VERBOSE']) { + $this->logger('MyMssql Exec: '.$sql); + } + + return empty($stmt) ? false : true; } catch (Exception $e) { $err = $e->getMessage(); $this->logger('MyMssql Exec '.$this->ini['ADAPTER'], $err); @@ -306,7 +323,7 @@ public function exec($sql) public function execScript($sql) { try { - $stmt = $this->exec($sql); + $stmt = $this->query($sql); if (true == $this->ini['VERBOSE']) { $this->logger('MyMssql Exec Script: '.$sql); @@ -429,7 +446,7 @@ private function querySx($sxName, $params, $test = false, $function = 'exec') } if ('exec' === $function) { - $stmt = $this->exec($sql); + $stmt = $this->query($sql); $result = false; if ('SQLSRV' == $this->ini['ADAPTER']) {