\Cake\Database\SchemaCachedCollection

Extends the schema collection class to provide caching

Used to access information about the tables, and other data in a database.

Summary

Methods
Properties
Constants
__construct()
listTables()
describe()
cacheKey()
setCacheMetadata()
getCacheMetadata()
cacheMetadata()
No public properties found
No constants found
_reflect()
$_connection
$_dialect
$_cache
N/A
No private methods found
No private properties found
N/A

Properties

$_cache

$_cache : string|boolean

The name of the cache config key to use for caching table metadata, of false if disabled.

Type

string|boolean

Methods

__construct()

__construct(\Cake\Datasource\ConnectionInterface  $connection, string|boolean  $cacheKey = true) 

Constructor.

Parameters

\Cake\Datasource\ConnectionInterface $connection

The connection instance.

string|boolean $cacheKey

The cache key or boolean false to disable caching.

listTables()

listTables() : array

Get the list of tables available in the current connection.

Returns

array —

The list of tables in the connected database/schema.

describe()

describe(string  $name, array  $options = array()) : \Cake\Database\Schema\TableSchema

Get the column metadata for a table.

Caching will be applied if cacheMetadata key is present in the Connection configuration options. Defaults to _cakemodel when true.

Options

  • forceRefresh - Set to true to force rebuilding the cached metadata. Defaults to false.

Parameters

string $name

The name of the table to describe.

array $options

The options to use, see above.

Returns

\Cake\Database\Schema\TableSchema

Object with column metadata.

cacheKey()

cacheKey(string  $name) : string

Get the cache key for a given name.

Parameters

string $name

The name to get a cache key for.

Returns

string —

The cache key.

setCacheMetadata()

setCacheMetadata(boolean  $enable) : $this

Sets the cache config name to use for caching table metadata, or disables it if false is passed.

Parameters

boolean $enable

Whether or not to enable caching

Returns

$this

getCacheMetadata()

getCacheMetadata() : string|boolean

Gets the cache config name to use for caching table metadata, false means disabled.

Returns

string|boolean

cacheMetadata()

cacheMetadata(boolean|null  $enable = null) : string|boolean

Sets the cache config name to use for caching table metadata, or disables it if false is passed.

If called with no arguments it returns the current configuration name.

Parameters

boolean|null $enable

Whether or not to enable caching

Returns

string|boolean

_reflect()

_reflect(string  $stage, string  $name, array  $config, \Cake\Database\Schema\TableSchema  $schema) : void

Helper method for running each step of the reflection process.

Parameters

string $stage

The stage name.

string $name

The table name.

array $config

The config data.

\Cake\Database\Schema\TableSchema $schema

The table instance

Throws

\Cake\Database\Exception

on query failure.