File indexing completed on 2025-01-19 05:21:03
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Db 0017 * @subpackage Table 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * Class for SQL table interface. 0025 * 0026 * @category Zend 0027 * @package Zend_Db 0028 * @subpackage Table 0029 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0030 * @license http://framework.zend.com/license/new-bsd New BSD License 0031 */ 0032 class Zend_Db_Table_Definition 0033 { 0034 0035 /** 0036 * @var array 0037 */ 0038 protected $_tableConfigs = array(); 0039 0040 /** 0041 * __construct() 0042 * 0043 * @param array|Zend_Config $options 0044 */ 0045 public function __construct($options = null) 0046 { 0047 if ($options instanceof Zend_Config) { 0048 $this->setConfig($options); 0049 } elseif (is_array($options)) { 0050 $this->setOptions($options); 0051 } 0052 } 0053 0054 /** 0055 * setConfig() 0056 * 0057 * @param Zend_Config $config 0058 * @return Zend_Db_Table_Definition 0059 */ 0060 public function setConfig(Zend_Config $config) 0061 { 0062 $this->setOptions($config->toArray()); 0063 return $this; 0064 } 0065 0066 /** 0067 * setOptions() 0068 * 0069 * @param array $options 0070 * @return Zend_Db_Table_Definition 0071 */ 0072 public function setOptions(Array $options) 0073 { 0074 foreach ($options as $optionName => $optionValue) { 0075 $this->setTableConfig($optionName, $optionValue); 0076 } 0077 return $this; 0078 } 0079 0080 /** 0081 * @param string $tableName 0082 * @param array $tableConfig 0083 * @return Zend_Db_Table_Definition 0084 */ 0085 public function setTableConfig($tableName, array $tableConfig) 0086 { 0087 // @todo logic here 0088 $tableConfig[Zend_Db_Table::DEFINITION_CONFIG_NAME] = $tableName; 0089 $tableConfig[Zend_Db_Table::DEFINITION] = $this; 0090 0091 if (!isset($tableConfig[Zend_Db_Table::NAME])) { 0092 $tableConfig[Zend_Db_Table::NAME] = $tableName; 0093 } 0094 0095 $this->_tableConfigs[$tableName] = $tableConfig; 0096 return $this; 0097 } 0098 0099 /** 0100 * getTableConfig() 0101 * 0102 * @param string $tableName 0103 * @return array 0104 */ 0105 public function getTableConfig($tableName) 0106 { 0107 return $this->_tableConfigs[$tableName]; 0108 } 0109 0110 /** 0111 * removeTableConfig() 0112 * 0113 * @param string $tableName 0114 */ 0115 public function removeTableConfig($tableName) 0116 { 0117 unset($this->_tableConfigs[$tableName]); 0118 } 0119 0120 /** 0121 * hasTableConfig() 0122 * 0123 * @param string $tableName 0124 * @return bool 0125 */ 0126 public function hasTableConfig($tableName) 0127 { 0128 return (isset($this->_tableConfigs[$tableName])); 0129 } 0130 0131 }