From: Andrey Kutejko Date: Sat, 27 Jul 2013 21:23:24 +0000 (+0300) Subject: make columnCount calculatable X-Git-Tag: 0.5~114 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=4ee017605a998542e9f11b5c562bba984595eabb;p=ipf.git make columnCount calculatable --- diff --git a/ipf/orm/table.php b/ipf/orm/table.php index af035c0..c6427c7 100644 --- a/ipf/orm/table.php +++ b/ipf/orm/table.php @@ -14,8 +14,6 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable protected $_columnNames = array(); - protected $columnCount; - protected $hasDefaultValues; protected $_options = array('name' => null, @@ -57,8 +55,6 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable // create database table $name::setTableDefinition($this); - $this->columnCount = count($this->_columns); - if (!isset($this->_options['tableName'])) { $this->setTableName(IPF_ORM_Inflector::tableize($class->getName())); } @@ -105,7 +101,6 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable $this->setColumn('id', $definition['type'], $definition['length'], $definition, true); $this->_identifier = 'id'; $this->_identifierType = IPF_ORM::IDENTIFIER_AUTOINC; - $this->columnCount++; break; case 1: foreach ($this->_identifier as $pk) { @@ -823,7 +818,7 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable public function getColumnCount() { - return $this->columnCount; + return count($this->_columns); } public function getColumns() @@ -833,14 +828,13 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable public function removeColumn($fieldName) { - if ( ! $this->hasField($fieldName)) { - return false; + if ($this->hasField($fieldName)) { + $columnName = $this->getColumnName($fieldName); + unset($this->_columnNames[$fieldName], $this->_fieldNames[$columnName], $this->_columns[$columnName]); + return true; + } else { + return false; } - - $columnName = $this->getColumnName($fieldName); - unset($this->_columnNames[$fieldName], $this->_fieldNames[$columnName], $this->_columns[$columnName]); - $this->columnCount = count($this->_columns); - return true; } public function getColumnNames(array $fieldNames = null)