]> git.mxchange.org Git - friendica.git/blobdiff - include/dba_pdo.php
merged 2 if() into one as requested by CR
[friendica.git] / include / dba_pdo.php
index 7cd8c638e7f60955364b93b3ea84a591a5b29adc..a44c447af20fa568d8ed15bb6e6082fc5330b182 100644 (file)
@@ -44,7 +44,7 @@ class dba {
        public  $error = false;
 
        function __construct($server,$user,$pass,$db,$install = false) {
-               global $a;
+               $a = get_app();
     
     # work around, to store the database - configuration in DDDBL
     $objDataObjectPool = new \DDDBL\DataObjectPool('Database-Definition');
@@ -99,7 +99,7 @@ class dba {
        }
 
        public function q($sql, $onlyquery = false) {
-               global $a;
+               $a = get_app();
 
     $strHandler = (true === $onlyquery) ? 'PDOStatement' : 'MULTI';
     
@@ -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,13 +182,13 @@ 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) {