Changeset 342 for trunk/database.php
- Timestamp:
- Jan 17, 2012, 10:37:59 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/database.php
r336 r342 44 44 else $ConnectionString = ''; 45 45 $this->PDO = new PDO($ConnectionString, $User, $Password); 46 $this->PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 46 47 } 47 48 … … 53 54 function query($Query) 54 55 { 55 $this->LastQuery = $Query; 56 if($this->ShowSQLQuery == true) 57 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>'."\n"); 58 $Result = new DatabaseResult(); 59 $Result->PDOStatement = $this->PDO->query($Query); 60 if($Result->PDOStatement) 56 try 61 57 { 62 $Result->num_rows = $Result->PDOStatement->rowCount(); 63 } else 58 $this->LastQuery = $Query; 59 if($this->ShowSQLQuery == true) 60 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>'."\n"); 61 $Result = new DatabaseResult(); 62 $Result->PDOStatement = $this->PDO->query($Query); 63 if($Result->PDOStatement) 64 $Result->num_rows = $Result->PDOStatement->rowCount(); 65 } catch(PDOException $E) 64 66 { 65 $this->Error = $this->PDO->errorInfo(); 66 $this->Error = $this->Error[2]; 67 $this->Error = $E->getMessage(); 67 68 if(($this->Error != '') and ($this->ShowSQLError == true)) 68 69 echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>'); … … 115 116 foreach($Data as $Key => $Value) 116 117 { 117 118 if(!in_array($Value, $this->Functions)) $Value = $this->PDO->quote($Value); 118 119 $Name .= ',`'.$Key.'`'; 119 120 $Values .= ','.$Value;
Note:
See TracChangeset
for help on using the changeset viewer.