Ignore:
Timestamp:
Mar 16, 2014, 11:15:43 AM (11 years ago)
Author:
chronos
Message:
  • Added: Module Redirection responsible for redirection of old pages to new valid address.
  • Fixed: Error on client version item display if id was not specified.
  • Fixed: Error on silent application module reregistration.
  • Removed: White space on end of lines in some files.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/Database.php

    r770 r800  
    88  var $PDOStatement;
    99  var $num_rows = 0;
    10  
     10
    1111  function fetch_assoc()
    1212  {
    1313    return($this->PDOStatement->fetch(PDO::FETCH_ASSOC));
    1414  }
    15  
     15
    1616  function fetch_array()
    1717  {
     
    2929  var $Prefix;
    3030  var $Functions;
    31   var $Type; 
     31  var $Type;
    3232  var $PDO;
    3333  var $Error;
     
    3737  var $ShowSQLQuery;
    3838  var $LogFile;
    39  
     39
    4040  function __construct()
    41   {   
     41  {
    4242        $this->Functions = array('NOW()', 'CURDATE()', 'CURTIME()', 'UUID()');
    4343        $this->Type = 'mysql'; // mysql, pgsql
     
    4747        $this->LogFile = dirname(__FILE__).'/../Query.log';
    4848  }
    49  
     49
    5050  function Connect($Host, $User, $Password, $Database)
    51   {   
     51  {
    5252    if($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database;
    5353      else if($this->Type == 'pgsql') $ConnectionString = 'pgsql:dbname='.$Database.';host='.$Host;
     
    5555    $this->PDO = new PDO($ConnectionString, $User, $Password);
    5656  }
    57  
     57
    5858  function select_db($Database)
    5959  {
    6060    $this->query('USE `'.$Database.'`');
    6161  }
    62  
     62
    6363  function query($Query)
    6464  {
     
    6767    $Result = new DatabaseResult();
    6868    $Result->PDOStatement = $this->PDO->query($Query);
    69     if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) 
    70       $Duration = ' ; '.round(microtime() - $QueryStartTime, 3). ' s';
     69    if(($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true))
     70      $Duration = ' ; '.round(microtime() - $QueryStartTime, 4). ' s';
    7171    if($this->LogSQLQuery == true)
    7272      file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND);
     
    8181      $this->Error = $this->PDO->errorInfo();
    8282      $this->Error = $this->Error[2];
    83       if(($this->Error != '') and ($this->ShowSQLError == true)) 
     83      if(($this->Error != '') and ($this->ShowSQLError == true))
    8484        echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>');
    8585        throw new Exception('SQL Error: '.$this->Error);
    8686    }
    87     return($Result); 
     87    return($Result);
    8888  }
    8989
    9090  function select($Table, $What = '*', $Condition = 1)
    91   {   
    92     return($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition)); 
     91  {
     92    return($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition));
    9393  }
    9494
    9595  function delete($Table, $Condition)
    9696  {
    97     $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 
    98   }
    99  
     97    $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition);
     98  }
     99
    100100  function insert($Table, $Data)
    101101  {
     
    105105    {
    106106      $Name .= ',`'.$Key.'`';
    107       if(!in_array($Value, $this->Functions)) 
     107      if(!in_array($Value, $this->Functions))
    108108      {
    109109        if(is_null($Value)) $Value = 'NULL';
     
    114114    $Name = substr($Name, 1);
    115115    $Values = substr($Values, 1);
    116     $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 
     116    $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
    117117    $this->insert_id = $this->PDO->lastInsertId();
    118118  }
    119  
     119
    120120  function update($Table, $Condition, $Data)
    121121  {
     
    123123    foreach($Data as $Key => $Value)
    124124    {
    125       if(!in_array($Value, $this->Functions)) 
     125      if(!in_array($Value, $this->Functions))
    126126      {
    127127        if(is_null($Value)) $Value = 'NULL';
     
    130130      $Values .= ', `'.$Key.'`='.$Value;
    131131    }
    132     $Values = substr($Values, 2); 
     132    $Values = substr($Values, 2);
    133133    $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
    134134  }
    135  
     135
    136136  function replace($Table, $Data)
    137137  {
     
    140140    foreach($Data as $Key => $Value)
    141141    {
    142       if(!in_array($Value, $this->Functions)) 
     142      if(!in_array($Value, $this->Functions))
    143143      {
    144144        if(is_null($Value)) $Value = 'NULL';
     
    154154    //echo($this->error().'<br>');
    155155  }
    156  
     156
    157157  function charset($Charset)
    158158  {
    159159    $this->query('SET NAMES "'.$Charset.'"');
    160160  }
    161  
     161
    162162  function real_escape_string($Text)
    163163  {
    164164    return(addslashes($Text));
    165165  }
    166  
     166
    167167  function quote($Text)
    168168  {
    169169        return($this->PDO->quote($Text));
    170170  }
    171  
     171
    172172  function __sleep()
    173173  {
     
    177177  function __wakeup()
    178178  {
    179   } 
     179  }
    180180}
    181181
     
    183183{
    184184  if($Time == NULL) return(NULL);
    185     else return(date('Y-m-d H:i:s', $Time)); 
     185    else return(date('Y-m-d H:i:s', $Time));
    186186}
    187187
     
    189189{
    190190  if($Time == NULL) return(NULL);
    191     else return(date('Y-m-d', $Time)); 
     191    else return(date('Y-m-d', $Time));
    192192}
    193193
     
    195195{
    196196  if($Time == NULL) return(NULL);
    197     else return(date('H:i:s', $Time)); 
     197    else return(date('H:i:s', $Time));
    198198}
    199199
    200200function MysqlDateTimeToTime($DateTime)
    201201{
    202   if($DateTime == '') return(0);     
     202  if($DateTime == '') return(0);
    203203  $Parts = explode(' ', $DateTime);
    204   $DateParts = explode('-', $Parts[0]); 
     204  $DateParts = explode('-', $Parts[0]);
    205205  $TimeParts = explode(':', $Parts[1]);
    206   $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]); 
    207   return($Result); 
     206  $Result = mktime($TimeParts[0], $TimeParts[1], $TimeParts[2], $DateParts[1], $DateParts[2], $DateParts[0]);
     207  return($Result);
    208208}
    209209
     
    211211{
    212212  if($Date == '') return(0);
    213   return(MysqlDateTimeToTime($Date.' 0:0:0')); 
     213  return(MysqlDateTimeToTime($Date.' 0:0:0'));
    214214}
    215215
     
    217217{
    218218  if($Time == '') return(0);
    219   return(MysqlDateTimeToTime('0000-00-00 '.$Time)); 
    220 }
     219  return(MysqlDateTimeToTime('0000-00-00 '.$Time));
     220}
Note: See TracChangeset for help on using the changeset viewer.