protected $_columnNames = array();
- protected $columnCount;
-
protected $hasDefaultValues;
protected $_options = array('name' => null,
// create database table
$name::setTableDefinition($this);
- $this->columnCount = count($this->_columns);
-
if (!isset($this->_options['tableName'])) {
$this->setTableName(IPF_ORM_Inflector::tableize($class->getName()));
}
$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) {
public function getColumnCount()
{
- return $this->columnCount;
+ return count($this->_columns);
}
public function getColumns()
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)