]> git.mxchange.org Git - friendica.git/blobdiff - include/dba_pdo.php
regenerated credits.txt
[friendica.git] / include / dba_pdo.php
index 76937e7f95e1b98e32f02f14fdf7474331920838..7b720fb6c1217e31be5ae0368ea9facbdfcf229e 100644 (file)
@@ -100,7 +100,7 @@ class dba {
 
        public function q($sql, $onlyquery = false) {
                global $a;
-    
+
     $strHandler = (true === $onlyquery) ? 'PDOStatement' : 'MULTI';
     
     $strQueryAlias = md5($sql);
@@ -126,6 +126,7 @@ class dba {
       # bad workaround to emulate the bizzare behavior of mysql_query
       if(in_array($strSQLType, array('INSERT', 'UPDATE', 'DELETE', 'CREATE', 'DROP', 'SET')))
         $result = true;
+      $intErrorCode = false;
         
     } catch (\Exception $objException) {
       $result = false;
@@ -181,17 +182,18 @@ class dba {
                 * These usually indicate SQL syntax errors that need to be resolved.
                 */
 
-               if($result === false) {
+               if(isset($result) AND ($result === false)) {
                        logger('dba: ' . printable($sql) . ' returned false.' . "\n" . $this->error);
                        if(file_exists('dbfail.out'))
                                file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n" . $this->error . "\n", FILE_APPEND);
                }
 
-               if(($result === true) || ($result === false))
+               if(isset($result) AND (($result === true) || ($result === false)))
                        return $result;
-
+    
                if ($onlyquery) {
-                       $this->result = $result;
+                       $this->result = $r;       # this will store an PDOStatement Object in result
+      $this->result->execute(); # execute the Statement, to get its result
                        return true;
                }
     
@@ -203,17 +205,17 @@ class dba {
        }
 
        public function qfetch() {
-  
-               if (!$this->result)
+
+               if (false === $this->result)
       return false;
-      
+
     return $this->result->fetch();
 
        }
   
        public function qclose() {
                if ($this->result)
-      $this->result->closeCursor();
+      return $this->result->closeCursor();
        }
 
        public function dbg($dbg) {
@@ -337,4 +339,3 @@ if(! function_exists('dba_timer')) {
 function dba_timer() {
   return microtime(true);
 }}
-