Changeset 153 for www/database.php


Ignore:
Timestamp:
Feb 16, 2009, 6:16:00 PM (15 years ago)
Author:
george
Message:
  • Přidáno: Zobrazování chyb v SQL povelech. Nastavení v konfigureaci.
  • Upraveno: Zpřístupnění stavu financí dle ip i dle přihlášení.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • www/database.php

    r148 r153  
    22
    33// Extended database class
    4 // Date: 2007-07-19
     4// Date: 2009-02-16
    55
    66class Database extends mysqli
    77{
    88  var $Prefix = '';
    9   var $LastQuery = '';
    109 
    1110  function query($Query)
    1211  {
    13     $this->LastQuery = $Query;
    14     return(parent::query($Query)); 
     12        global $Config;
     13       
     14        if($Config['Web']['ShowSQLQuery'] == true)
     15          echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.'</div>');
     16        $Result = parent::query($Query);
     17    if(($this->error != '') and ($Config['Web']['ShowSQLError'] == true))
     18          echo('<div><strong>SQL Error: </strong>'.$this->error.'<br>'.$Query.'</div>');
     19
     20    return($Result); 
    1521  }
    1622
    1723  function select($Table, $What = '*', $Condition = 1)
    1824  {
    19     $this->LastQuery = "SELECT ".$What." FROM `".$this->Prefix.$Table."` WHERE ".$Condition;
    20     return($this->query($this->LastQuery)); 
     25    return($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition)); 
    2126  }
    2227
    2328  function delete($Table, $Condition)
    2429  {
    25     $this->LastQuery = "DELETE FROM `".$this->Prefix.$Table."` WHERE ".$Condition;
    26     $this->query($this->LastQuery); 
     30    $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 
    2731  }
    2832 
     
    4145    $Name = substr($Name, 1);
    4246    $Values = substr($Values, 1);
    43     $this->LastQuery = 'INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')';
    44     $this->query($this->LastQuery);
     47    $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
    4548  }
    4649 
     
    5558    }
    5659    $Values = substr($Values, 2); 
    57     $this->LastQuery = 'UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')';
    58     $this->query($this->LastQuery);
     60    $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
    5961  }
    6062 
     
    7375    $Values = substr($Values, 1);
    7476    //echo('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES ('.$Values.')<br>');
    75     $this->LastQuery = 'REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')';
    76     $this->query($this->LastQuery);
     77    $this->query('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
    7778    //echo($this->error().'<br>');
    7879  }
     
    8081  function charset($Charset)
    8182  {
    82     $this->LastQuery = "SET NAMES '".$Charset."'";
    83     $this->query($this->LastQuery);
     83    $this->query('SET NAMES "'.$Charset.'"');
    8484  }
    8585
Note: See TracChangeset for help on using the changeset viewer.