CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • Connection
  • Driver
  • FieldTypeConverter
  • FunctionsBuilder
  • Query
  • SchemaCache
  • Type
  • TypeMap

Interfaces

  • DriverInterface
  • ExpressionInterface
  • StatementInterface
  • TypedResultInterface
  • TypeInterface

Traits

  • SqlDialectTrait
  • TypeConverterTrait
  • TypedResultTrait
  • TypeMapTrait

Exceptions

  • Exception
  1: <?php
  2: /**
  3:  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4:  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5:  *
  6:  * Licensed under The MIT License
  7:  * For full copyright and license information, please see the LICENSE.txt
  8:  * Redistributions of files must retain the above copyright notice.
  9:  *
 10:  * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 11:  * @link          https://cakephp.org CakePHP(tm) Project
 12:  * @since         3.6.0
 13:  * @license       https://opensource.org/licenses/mit-license.php MIT License
 14:  */
 15: namespace Cake\Database;
 16: 
 17: use Cake\Cache\Cache;
 18: use Cake\Database\Connection;
 19: use RuntimeException;
 20: 
 21: /**
 22:  * Schema Cache.
 23:  *
 24:  * This tool is intended to be used by deployment scripts so that you
 25:  * can prevent thundering herd effects on the metadata cache when new
 26:  * versions of your application are deployed, or when migrations
 27:  * requiring updated metadata are required.
 28:  */
 29: class SchemaCache
 30: {
 31:     /**
 32:      * Schema
 33:      *
 34:      * @var \Cake\Database\Schema\CachedCollection
 35:      */
 36:     protected $_schema;
 37: 
 38:     /**
 39:      * Constructor
 40:      *
 41:      * @param string|\Cake\Datasource\ConnectionInterface $connection Connection name to get the schema for or a connection instance
 42:      */
 43:     public function __construct($connection)
 44:     {
 45:         $this->_schema = $this->getSchema($connection);
 46:     }
 47: 
 48:     /**
 49:      * Build metadata.
 50:      *
 51:      * @param string|null $name The name of the table to build cache data for.
 52:      * @return array Returns a list build table caches
 53:      */
 54:     public function build($name = null)
 55:     {
 56:         $tables = [$name];
 57:         if (empty($name)) {
 58:             $tables = $this->_schema->listTables();
 59:         }
 60: 
 61:         foreach ($tables as $table) {
 62:             $this->_schema->describe($table, ['forceRefresh' => true]);
 63:         }
 64: 
 65:         return $tables;
 66:     }
 67: 
 68:     /**
 69:      * Clear metadata.
 70:      *
 71:      * @param string|null $name The name of the table to clear cache data for.
 72:      * @return array Returns a list of cleared table caches
 73:      */
 74:     public function clear($name = null)
 75:     {
 76:         $tables = [$name];
 77:         if (empty($name)) {
 78:             $tables = $this->_schema->listTables();
 79:         }
 80:         $configName = $this->_schema->getCacheMetadata();
 81: 
 82:         foreach ($tables as $table) {
 83:             $key = $this->_schema->cacheKey($table);
 84:             Cache::delete($key, $configName);
 85:         }
 86: 
 87:         return $tables;
 88:     }
 89: 
 90:     /**
 91:      * Helper method to get the schema collection.
 92:      *
 93:      * @param \Cake\Database\Connection $connection Connection object
 94:      * @return \Cake\Database\Schema\Collection|\Cake\Database\Schema\CachedCollection
 95:      * @throws \RuntimeException If given connection object is not compatible with schema caching
 96:      */
 97:     public function getSchema(Connection $connection)
 98:     {
 99:         if (!method_exists($connection, 'schemaCollection')) {
100:             throw new RuntimeException('The given connection object is not compatible with schema caching, as it does not implement a "schemaCollection()" method.');
101:         }
102: 
103:         $config = $connection->config();
104:         if (empty($config['cacheMetadata'])) {
105:             $connection->cacheMetadata(true);
106:         }
107: 
108:         return $connection->getSchemaCollection();
109:     }
110: }
111: 
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs