Changeset 13
- Timestamp:
- 10/09/06 02:40:15
- Files:
-
- trunk/phptagengine.class.inc.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/phptagengine.class.inc.php
r12 r13 2 2 3 3 // Copyright (c) 2006 Alex King. All rights reserved. 4 // http:// www.alexking.org/software/phptagengine/4 // http://alexking.org/projects/php-tag-engine 5 5 // 6 6 // Released under the LGPL license … … 33 33 var $db; 34 34 /** 35 * Column name escape string for the database being used. Checks for: mysql, postgres7, mssql 36 * 37 * @var string 38 */ 39 var $db_col_escape_char; 40 /** 35 41 * Name of the tags table in the database 36 42 * … … 181 187 $this->language = 'english'; 182 188 $this->charset = 'UTF-8'; 189 $this->db_type = 'mysql'; 183 190 $this->strings = array(); 184 191 $this->tag_browse_url = 'http://example.com/index.php?view=tags&tag=<tag>&type=<type>'; … … 196 203 $this->version = '1.0'; 197 204 } 205 206 /** 207 * Sets the character used for escaping column names for the database type in use 208 */ 209 function set_db_col_escape_char() { 210 switch ($this->db->databaseType) { 211 case 'mysql': 212 $this->db_col_escape_char = '`'; 213 break; 214 case 'postgres7': 215 case 'mssql': 216 $this->db_col_escape_char = '"'; 217 break; 218 } 219 } 198 220 199 221 /** … … 267 289 INSERT 268 290 INTO $this->table_tag_names 269 ( name291 ( ".$this->db_col_escape_char."name".$this->db_col_escape_char." 270 292 ) 271 293 VALUES … … 273 295 ) 274 296 ") or die($this->db->ErrorMsg().' in '.__FILE__); 297 275 298 if ($result) { 276 return $this->db->Insert_ID(); 277 } 299 $id = false; 300 if (strstr($this->db->databaseType, 'postgres')) { 301 $id = $this->db->GetOne(" 302 SELECT CURRVAL('".$this->table_tag_names."_id_seq') as id 303 ") or die($this->db->ErrorMsg()); 304 } 305 else { 306 $id = $this->db->Insert_ID(); 307 } 308 return $id; 309 } 310 278 311 return false; 279 312 } … … 305 338 } 306 339 else { 340 $this->set_db_col_escape_char(); 307 341 $result = $this->db->Execute(" 308 342 INSERT 309 343 INTO $this->table_tags 310 ( $this->table_tags.user311 , $this->table_tags.item312 , $this->table_tags.type313 , $this->table_tags.tag314 , $this->table_tags.date344 ( ".$this->db_col_escape_char."user".$this->db_col_escape_char." 345 , ".$this->db_col_escape_char."item".$this->db_col_escape_char." 346 , ".$this->db_col_escape_char."type".$this->db_col_escape_char." 347 , ".$this->db_col_escape_char."tag".$this->db_col_escape_char." 348 , ".$this->db_col_escape_char."date".$this->db_col_escape_char." 315 349 ) 316 350 VALUES
