*prechod na novsiu verziu ZF
[sport-group.git] / library / Zend / Db / Table / Definition.php
blobedea0ee64055db2f176fdc2d500bff4fea6cf3b7
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
15 * @category Zend
16 * @package Zend_Db
17 * @subpackage Table
18 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: Definition.php 16971 2009-07-22 18:05:45Z mikaelkael $
23 /**
24 * Class for SQL table interface.
26 * @category Zend
27 * @package Zend_Db
28 * @subpackage Table
29 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
30 * @license http://framework.zend.com/license/new-bsd New BSD License
32 class Zend_Db_Table_Definition
35 /**
36 * @var array
38 protected $_tableConfigs = array();
40 /**
41 * __construct()
43 * @param array|Zend_Config $options
45 public function __construct($options = null)
47 if ($options instanceof Zend_Config) {
48 $this->setConfig($options);
49 } elseif (is_array($options)) {
50 $this->setOptions($options);
54 /**
55 * setConfig()
57 * @param Zend_Config $config
58 * @return Zend_Db_Table_Definition
60 public function setConfig(Zend_Config $config)
62 $this->setOptions($config->toArray());
63 return $this;
66 /**
67 * setOptions()
69 * @param array $options
70 * @return Zend_Db_Table_Definition
72 public function setOptions(Array $options)
74 foreach ($options as $optionName => $optionValue) {
75 $this->setTableConfig($optionName, $optionValue);
77 return $this;
80 /**
81 * @param string $tableName
82 * @param array $tableConfig
83 * @return Zend_Db_Table_Definition
85 public function setTableConfig($tableName, array $tableConfig)
87 // @todo logic here
88 $tableConfig[Zend_Db_Table::DEFINITION_CONFIG_NAME] = $tableName;
89 $tableConfig[Zend_Db_Table::DEFINITION] = $this;
91 if (!isset($tableConfig[Zend_Db_Table::NAME])) {
92 $tableConfig[Zend_Db_Table::NAME] = $tableName;
95 $this->_tableConfigs[$tableName] = $tableConfig;
96 return $this;
99 /**
100 * getTableConfig()
102 * @param string $tableName
103 * @return array
105 public function getTableConfig($tableName)
107 return $this->_tableConfigs[$tableName];
111 * removeTableConfig()
113 * @param string $tableName
115 public function removeTableConfig($tableName)
117 unset($this->_tableConfigs[$tableName]);
121 * hasTableConfig()
123 * @param string $tableName
124 * @return bool
126 public function hasTableConfig($tableName)
128 return (isset($this->_tableConfigs[$tableName]));