Changeset 19 for trunk/Database.php
- Timestamp:
- Sep 6, 2019, 9:44:30 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Database.php
r10 r19 57 57 $this->LogFile = dirname(__FILE__).'/../../Query.log'; 58 58 } 59 59 60 60 61 61 function Connect($Host, $User, $Password, $Database) … … 109 109 $this->insert_id = $this->PDO->lastInsertId(); 110 110 } else 111 { 111 { 112 112 $this->Error = $this->PDO->errorInfo(); 113 113 $this->Error = $this->Error[2]; … … 134 134 $this->insert_id = $this->PDO->lastInsertId(); 135 135 } 136 136 137 137 function GetInsert($Table, $Data) 138 138 { … … 158 158 $this->query($this->GetUpdate($Table, $Condition, $Data)); 159 159 } 160 160 161 161 function GetUpdate($Table, $Condition, $Data) 162 162 { … … 219 219 { 220 220 } 221 221 222 222 public function Transaction($Queries) 223 223 { 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 } 231 238 } 232 239 }
Note:
See TracChangeset
for help on using the changeset viewer.