Changeset 2166
- Timestamp:
- 02/25/2008 11:11:19 AM (11 months ago)
- Location:
- releases/2.1.2/system/libraries
- Files:
-
- 3 modified
-
Database.php (modified) (1 diff)
-
drivers/Database/Pdosqlite.php (modified) (1 diff)
-
drivers/Database/Pgsql.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
releases/2.1.2/system/libraries/Database.php
r1961 r2166 1057 1057 1058 1058 /** 1059 * Escapes a table name for a query. 1060 * 1061 * @param string string to escape 1062 * @return string 1063 */ 1064 public function escape_table($table) 1065 { 1066 return $this->driver->escape_table($table); 1067 } 1068 1069 /** 1070 * Escapes a column name for a query. 1071 * 1072 * @param string string to escape 1073 * @return string 1074 */ 1075 public function escape_column($table) 1076 { 1077 return $this->driver->escape_column($table); 1078 } 1079 1080 /** 1059 1081 * Returns table prefix of current configuration. 1060 1082 * -
releases/2.1.2/system/libraries/drivers/Database/Pdosqlite.php
r1906 r2166 257 257 } 258 258 else 259 { 260 return 'PRAGMA table_info('.$this->escape_table($table).')'; 259 { 260 $result = $this->link->query( 'PRAGMA table_info('.$this->escape_table($table).')' ); 261 262 foreach($result as $row) 263 { 264 $tables[$table][$row['name']] = $this->sql_type($row['type']); 265 } 266 267 return $tables[$table]; 261 268 } 262 269 } -
releases/2.1.2/system/libraries/drivers/Database/Pgsql.php
r2109 r2166 88 88 public function escape_table($table) 89 89 { 90 return ' \''.str_replace('.', '"."', $table).'\'';90 return '"'.str_replace('.', '"."', $table).'"'; 91 91 } 92 92 … … 351 351 if (is_resource($result)) 352 352 { 353 $this->current_row = 0; 354 $this->total_rows = pg_num_rows($this->result); 355 $this->fetch_type = ($object === TRUE) ? 'pg_fetch_object' : 'pg_fetch_array'; 356 } 357 elseif (is_bool($result)) 358 { 359 if ($result == FALSE) 360 { 361 // SQL error 362 throw new Kohana_Database_Exception('database.error', pg_last_error().' - '.$sql); 353 // Its an DELETE, INSERT, REPLACE, or UPDATE query 354 if (preg_match('/^(?:delete|insert|replace|update)\s+/i', trim($sql), $matches)) 355 { 356 $this->insert_id = (strtolower($matches[0]) == 'insert') ? $this->get_insert_id($link) : FALSE; 357 $this->total_rows = pg_affected_rows($link); 363 358 } 364 359 else 365 360 { 366 // Its an DELETE, INSERT, REPLACE, or UPDATE query 367 $this->insert_id = $this->get_insert_id($link); 368 $this->total_rows = pg_affected_rows($link); 369 } 370 } 361 $this->current_row = 0; 362 $this->total_rows = pg_num_rows($this->result); 363 $this->fetch_type = ($object === TRUE) ? 'pg_fetch_object' : 'pg_fetch_array'; 364 } 365 } 366 else 367 throw new Kohana_Database_Exception('database.error', pg_last_error().' - '.$sql); 371 368 372 369 // Set result type
