Changeset 19 for trunk/Database.php


Ignore:
Timestamp:
Sep 6, 2019, 9:44:30 AM (5 years ago)
Author:
chronos
Message:
  • Fixed: Teams were not imported correctly. Some of them had empty names.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Database.php

    r10 r19  
    5757    $this->LogFile = dirname(__FILE__).'/../../Query.log';
    5858  }
    59  
     59
    6060
    6161  function Connect($Host, $User, $Password, $Database)
     
    109109      $this->insert_id = $this->PDO->lastInsertId();
    110110    } else
    111     {     
     111    {
    112112      $this->Error = $this->PDO->errorInfo();
    113113      $this->Error = $this->Error[2];
     
    134134    $this->insert_id = $this->PDO->lastInsertId();
    135135  }
    136  
     136
    137137  function GetInsert($Table, $Data)
    138138  {
     
    158158    $this->query($this->GetUpdate($Table, $Condition, $Data));
    159159  }
    160  
     160
    161161  function GetUpdate($Table, $Condition, $Data)
    162162  {
     
    219219  {
    220220  }
    221  
     221
    222222  public function Transaction($Queries)
    223223  {
    224       $this->PDO->beginTransaction();
    225       foreach ($Queries as $Query)
    226       {
    227         $Statement = $this->PDO->prepare($Query);
    228         $Statement->execute();
    229       }         
    230       $this->PDO->commit();
     224    $this->PDO->beginTransaction();
     225    foreach ($Queries as $Query)
     226    {
     227      $Statement = $this->PDO->prepare($Query);
     228      $Statement->execute();
     229    }
     230    if (!$this->PDO->commit())
     231    {
     232      $this->Error = $this->PDO->errorInfo();
     233      $this->Error = $this->Error[2];
     234      if(($this->Error != '') and ($this->ShowSQLError == true))
     235        echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>');
     236      throw new Exception('SQL Error: '.$this->Error.', Query: '.$Query);
     237    }
    231238  }
    232239}
Note: See TracChangeset for help on using the changeset viewer.