0001-Introspection-is-specific-to-a-config-group.-Cache-p.patch
| system/libraries/drivers/Database/Mssql.php | ||
|---|---|---|
| 20 | 20 |
protected $db_config; |
| 21 | 21 | |
| 22 | 22 |
/** |
| 23 |
* Performance caches. |
|
| 24 |
*/ |
|
| 25 |
protected $fields_cache; |
|
| 26 | ||
| 27 |
/** |
|
| 23 | 28 |
* Sets the config for the class. |
| 24 | 29 |
* |
| 25 | 30 |
* @param array database configuration |
| ... | ... | |
| 27 | 32 |
public function __construct($config) |
| 28 | 33 |
{
|
| 29 | 34 |
$this->db_config = $config; |
| 35 |
$this->fields_cache = array(); |
|
| 30 | 36 | |
| 31 | 37 |
Kohana::log('debug', 'MSSQL Database Driver Initialized');
|
| 32 | 38 |
} |
| ... | ... | |
| 272 | 278 | |
| 273 | 279 |
public function list_fields($table) |
| 274 | 280 |
{
|
| 275 |
static $tables; |
|
| 276 | ||
| 277 |
if (empty($tables[$table])) |
|
| 281 |
if (! array_key_exists($table, $this->fields_cache)) |
|
| 278 | 282 |
{
|
| 279 | 283 |
foreach ($this->field_data($table) as $row) |
| 280 | 284 |
{
|
| 281 | 285 |
// Make an associative array |
| 282 |
$tables[$table][$row->Field] = $this->sql_type($row->Type);
|
|
| 286 |
$this->fields_cache[$table][$row->Field] = $this->sql_type($row->Type);
|
|
| 283 | 287 |
} |
| 284 | 288 |
} |
| 285 | 289 | |
| 286 |
return $tables[$table];
|
|
| 290 |
return $this->fields_cache[$table];
|
|
| 287 | 291 |
} |
| 288 | 292 | |
| 289 | 293 |
public function field_data($table) |
| system/libraries/drivers/Database/Mysql.php | ||
|---|---|---|
| 22 | 22 |
protected $db_config; |
| 23 | 23 | |
| 24 | 24 |
/** |
| 25 |
* Performance caches. |
|
| 26 |
*/ |
|
| 27 |
protected $fields_cache; |
|
| 28 | ||
| 29 |
/** |
|
| 25 | 30 |
* Sets the config for the class. |
| 26 | 31 |
* |
| 27 | 32 |
* @param array database configuration |
| ... | ... | |
| 29 | 34 |
public function __construct($config) |
| 30 | 35 |
{
|
| 31 | 36 |
$this->db_config = $config; |
| 37 |
$this->fields_cache = array(); |
|
| 32 | 38 | |
| 33 | 39 |
Kohana::log('debug', 'MySQL Database Driver Initialized');
|
| 34 | 40 |
} |
| ... | ... | |
| 267 | 273 | |
| 268 | 274 |
public function list_tables() |
| 269 | 275 |
{
|
| 270 |
static $tables;
|
|
| 276 |
$tables = array();
|
|
| 271 | 277 | |
| 272 |
if (empty($tables) AND $query = $this->query('SHOW TABLES FROM '.$this->escape_table($this->db_config['connection']['database'])))
|
|
| 278 |
if ($query = $this->query('SHOW TABLES FROM '.$this->escape_table($this->db_config['connection']['database'])))
|
|
| 273 | 279 |
{
|
| 274 | 280 |
foreach ($query->result(FALSE) as $row) |
| 275 | 281 |
{
|
| ... | ... | |
| 287 | 293 | |
| 288 | 294 |
public function list_fields($table) |
| 289 | 295 |
{
|
| 290 |
static $tables; |
|
| 291 | ||
| 292 |
if (empty($tables[$table])) |
|
| 296 |
if (! array_key_exists($table, $this->fields_cache)) |
|
| 293 | 297 |
{
|
| 294 | 298 |
foreach ($this->field_data($table) as $row) |
| 295 | 299 |
{
|
| 296 | 300 |
// Make an associative array |
| 297 |
$tables[$table][$row->Field] = $this->sql_type($row->Type);
|
|
| 301 |
$this->fields_cache[$table][$row->Field] = $this->sql_type($row->Type);
|
|
| 298 | 302 | |
| 299 | 303 |
if ($row->Key === 'PRI' AND $row->Extra === 'auto_increment') |
| 300 | 304 |
{
|
| 301 | 305 |
// For sequenced (AUTO_INCREMENT) tables |
| 302 |
$tables[$table][$row->Field]['sequenced'] = TRUE;
|
|
| 306 |
$this->fields_cache[$table][$row->Field]['sequenced'] = TRUE;
|
|
| 303 | 307 |
} |
| 304 | 308 | |
| 305 | 309 |
if ($row->Null === 'YES') |
| 306 | 310 |
{
|
| 307 | 311 |
// Set NULL status |
| 308 |
$tables[$table][$row->Field]['null'] = TRUE;
|
|
| 312 |
$this->fields_cache[$table][$row->Field]['null'] = TRUE;
|
|
| 309 | 313 |
} |
| 310 | 314 |
} |
| 311 | 315 |
} |
| 312 | 316 | |
| 313 |
if (!isset($tables[$table]))
|
|
| 317 |
if (! array_key_exists($table, $this->fields_cache))
|
|
| 314 | 318 |
throw new Kohana_Database_Exception('database.table_not_found', $table);
|
| 315 | 319 | |
| 316 |
return $tables[$table];
|
|
| 320 |
return $this->fields_cache[$table];
|
|
| 317 | 321 |
} |
| 318 | 322 | |
| 319 | 323 |
public function field_data($table) |
| system/libraries/drivers/Database/Pdosqlite.php | ||
|---|---|---|
| 17 | 17 |
protected $link; |
| 18 | 18 |
protected $db_config; |
| 19 | 19 | |
| 20 |
/** |
|
| 21 |
* Performance caches. |
|
| 22 |
*/ |
|
| 23 |
protected $fields_cache; |
|
| 24 | ||
| 20 | 25 |
/* |
| 21 | 26 |
* Constructor: __construct |
| 22 | 27 |
* Sets up the config for the class. |
| ... | ... | |
| 28 | 33 |
public function __construct($config) |
| 29 | 34 |
{
|
| 30 | 35 |
$this->db_config = $config; |
| 36 |
$this->fields_cache = array(); |
|
| 31 | 37 | |
| 32 | 38 |
Kohana::log('debug', 'PDO:Sqlite Database Driver Initialized');
|
| 33 | 39 |
} |
| ... | ... | |
| 232 | 238 | |
| 233 | 239 |
public function list_fields($table, $query = FALSE) |
| 234 | 240 |
{
|
| 235 |
static $tables; |
|
| 236 | 241 |
if (is_object($query)) |
| 237 | 242 |
{
|
| 238 |
if (empty($tables[$table]))
|
|
| 243 |
if (! array_key_exists($table, $this->fields_cache))
|
|
| 239 | 244 |
{
|
| 240 |
$tables[$table] = array();
|
|
| 245 |
$this->fields_cache[$table] = array();
|
|
| 241 | 246 | |
| 242 | 247 |
foreach ($query->result() as $row) |
| 243 | 248 |
{
|
| 244 |
$tables[$table][] = $row->name;
|
|
| 249 |
$this->fields_cache[$table][] = $row->name;
|
|
| 245 | 250 |
} |
| 246 | 251 |
} |
| 247 | 252 | |
| 248 |
return $tables[$table];
|
|
| 253 |
return $this->fields_cache[$table];
|
|
| 249 | 254 |
} |
| 250 | 255 |
else |
| 251 | 256 |
{
|
| ... | ... | |
| 253 | 258 | |
| 254 | 259 |
foreach ($result as $row) |
| 255 | 260 |
{
|
| 256 |
$tables[$table][$row['name']] = $this->sql_type($row['type']);
|
|
| 261 |
$this->fields_cache[$table][$row['name']] = $this->sql_type($row['type']);
|
|
| 257 | 262 |
} |
| 258 | 263 | |
| 259 |
return $tables[$table];
|
|
| 264 |
return $this->fields_cache[$table];
|
|
| 260 | 265 |
} |
| 261 | 266 |
} |
| 262 | 267 | |
| system/libraries/drivers/Database/Pgsql.php | ||
|---|---|---|
| 16 | 16 |
protected $db_config; |
| 17 | 17 | |
| 18 | 18 |
/** |
| 19 |
* Performance caches. |
|
| 20 |
*/ |
|
| 21 |
protected $fields_cache; |
|
| 22 | ||
| 23 |
/** |
|
| 19 | 24 |
* Sets the config for the class. |
| 20 | 25 |
* |
| 21 | 26 |
* @param array database configuration |
| ... | ... | |
| 23 | 28 |
public function __construct($config) |
| 24 | 29 |
{
|
| 25 | 30 |
$this->db_config = $config; |
| 31 |
$this->fields_cache = array(); |
|
| 26 | 32 | |
| 27 | 33 |
Kohana::log('debug', 'PgSQL Database Driver Initialized');
|
| 28 | 34 |
} |
| ... | ... | |
| 251 | 257 | |
| 252 | 258 |
public function list_fields($table) |
| 253 | 259 |
{
|
| 254 |
static $tables; |
|
| 255 | ||
| 256 |
if (empty($tables[$table])) |
|
| 260 |
if (! array_key_exists($table, $this->fields_cache)) |
|
| 257 | 261 |
{
|
| 258 | 262 |
foreach ($this->field_data($table) as $row) |
| 259 | 263 |
{
|
| 260 | 264 |
// Make an associative array |
| 261 |
$tables[$table][$row->column_name] = $this->sql_type($row->data_type);
|
|
| 265 |
$this->fields_cache[$table][$row->column_name] = $this->sql_type($row->data_type);
|
|
| 262 | 266 | |
| 263 | 267 |
if (!strncmp($row->column_default, 'nextval(', 8))
|
| 264 | 268 |
{
|
| 265 |
$tables[$table][$row->column_name]['sequenced'] = TRUE;
|
|
| 269 |
$this->fields_cache[$table][$row->column_name]['sequenced'] = TRUE;
|
|
| 266 | 270 |
} |
| 267 | 271 | |
| 268 | 272 |
if ($row->is_nullable === 'YES') |
| 269 | 273 |
{
|
| 270 |
$tables[$table][$row->column_name]['null'] = TRUE;
|
|
| 274 |
$this->fields_cache[$table][$row->column_name]['null'] = TRUE;
|
|
| 271 | 275 |
} |
| 272 | 276 |
} |
| 273 | 277 |
} |
| 274 | 278 | |
| 275 |
if (!isset($tables[$table]))
|
|
| 279 |
if (! array_key_exists($table, $this->fields_cache))
|
|
| 276 | 280 |
throw new Kohana_Database_Exception('database.table_not_found', $table);
|
| 277 | 281 | |
| 278 |
return $tables[$table];
|
|
| 282 |
return $this->fields_cache[$table];
|
|
| 279 | 283 |
} |
| 280 | 284 | |
| 281 | 285 |
public function field_data($table) |