Example #1
0
 /**
  * Get the column metadata for a table.
  *
  * Caching will be applied if `cacheMetadata` key is present in the Connection
  * configuration options. Defaults to _cake_model_ when true.
  *
  * ### Options
  *
  * - `forceRefresh` - Set to true to force rebuilding the cached metadata.
  *   Defaults to false.
  *
  * @param string $name The name of the table to describe.
  * @param array $options The options to use, see above.
  * @return \Cake\Database\Schema\Table Object with column metadata.
  * @throws \Cake\Database\Exception when table cannot be described.
  */
 public function describe($name, array $options = [])
 {
     $config = $this->_connection->config();
     if (strpos($name, '.')) {
         list($config['schema'], $name) = explode('.', $name);
     }
     $table = new Table($name);
     $this->_reflect('Column', $name, $config, $table);
     if (count($table->columns()) === 0) {
         throw new Exception(sprintf('Cannot describe %s. It has 0 columns.', $name));
     }
     $this->_reflect('Index', $name, $config, $table);
     $this->_reflect('ForeignKey', $name, $config, $table);
     $this->_reflect('Options', $name, $config, $table);
     return $table;
 }
 /**
  * Get the column metadata for a table.
  *
  * Caching will be applied if `cacheMetadata` key is present in the Connection
  * configuration options. Defaults to _cake_method_ when true.
  *
  * ### Options
  *
  * - `forceRefresh` - Set to true to force rebuilding the cached metadata.
  *   Defaults to false.
  *
  * @param string $name The name of the table to describe.
  * @param array $options The options to use, see above.
  * @return \CakeDC\OracleDriver\Database\Schema\Method Object with method metadata.
  * @throws \Cake\Database\Exception when table cannot be described.
  */
 public function describe($name, array $options = [])
 {
     $config = $this->_connection->config();
     $methods = $this->getMethod($name);
     if (empty($methods)) {
         throw new Exception(sprintf('Cannot describe %s. Method not found.', $name));
     }
     $method = new Method($name);
     $this->_reflect($method, $name, $config);
     return $method;
 }