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.7 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.7
      • 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:     /**
 33:      * Schema
 34:      *
 35:      * @var \Cake\Database\Schema\CachedCollection
 36:      */
 37:     protected $_schema;
 38: 
 39:     /**
 40:      * Constructor
 41:      *
 42:      * @param string|\Cake\Datasource\ConnectionInterface $connection Connection name to get the schema for or a connection instance
 43:      */
 44:     public function __construct($connection)
 45:     {
 46:         $this->_schema = $this->getSchema($connection);
 47:     }
 48: 
 49:     /**
 50:      * Build metadata.
 51:      *
 52:      * @param string|null $name The name of the table to build cache data for.
 53:      * @return array Returns a list build table caches
 54:      */
 55:     public function build($name = null)
 56:     {
 57:         $tables = [$name];
 58:         if (empty($name)) {
 59:             $tables = $this->_schema->listTables();
 60:         }
 61: 
 62:         foreach ($tables as $table) {
 63:             $this->_schema->describe($table, ['forceRefresh' => true]);
 64:         }
 65: 
 66:         return $tables;
 67:     }
 68: 
 69:     /**
 70:      * Clear metadata.
 71:      *
 72:      * @param string|null $name The name of the table to clear cache data for.
 73:      * @return array Returns a list of cleared table caches
 74:      */
 75:     public function clear($name = null)
 76:     {
 77:         $tables = [$name];
 78:         if (empty($name)) {
 79:             $tables = $this->_schema->listTables();
 80:         }
 81:         $configName = $this->_schema->getCacheMetadata();
 82: 
 83:         foreach ($tables as $table) {
 84:             $key = $this->_schema->cacheKey($table);
 85:             Cache::delete($key, $configName);
 86:         }
 87: 
 88:         return $tables;
 89:     }
 90: 
 91:     /**
 92:      * Helper method to get the schema collection.
 93:      *
 94:      * @param \Cake\Database\Connection $connection Connection object
 95:      * @return \Cake\Database\Schema\Collection|\Cake\Database\Schema\CachedCollection
 96:      * @throws \RuntimeException If given connection object is not compatible with schema caching
 97:      */
 98:     public function getSchema(Connection $connection)
 99:     {
100:         if (!method_exists($connection, 'schemaCollection')) {
101:             throw new RuntimeException('The given connection object is not compatible with schema caching, as it does not implement a "schemaCollection()" method.');
102:         }
103: 
104:         $config = $connection->config();
105:         if (empty($config['cacheMetadata'])) {
106:             $connection->cacheMetadata(true);
107:         }
108: 
109:         return $connection->getSchemaCollection();
110:     }
111: }
112: 
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