/** * Populate static properties for this table module. * * @return void */ protected function _setup() { // get the database adapter if (!$this->_db) { $this->_db = $this->_getDefaultAdapter(); } if (!$this->_db instanceof Zend_Db_Adapter_Abstract) { throw new Zend_Db_Table_Exception('db object does not implement Zend_Db_Adapter_Abstract'); } // get the table name if (!$this->_name) { $this->_name = self::$_inflector->underscore(get_class($this)); } // get the table columns if (!$this->_cols) { $tmp = array_keys($this->_db->describeTable($this->_name)); foreach ($tmp as $native) { $this->_cols[$native] = self::$_inflector->camelize($native); } } // primary key if (!$this->_primary) { // none specified $table = $this->_name; throw new Zend_Db_Table_Exception("primary key not specified for table '{$table}'"); } elseif (!array_key_exists($this->_primary, $this->_cols)) { // wrong name $key = $this->_primary; $table = $this->_name; throw new Zend_Db_Table_Exception("primary key '{$key}' not in columns for table '{$table}'"); } }