Subversion Repositories PHPX

Compare Revisions

Last modification

Ignore whitespace Rev 57 → Rev 58

/trunk/Db/Table.php
22,8 → 22,30
protected static $_name = '';
 
/**
* Columns definition
* @var array
* @see Table::create()
*/
protected static $_columns;
 
/**
* Indexes definition
* @var array
* @see Table::create()
*/
protected static $_indexes;
 
/**
* Constraints definition
* @var array
* @see Table::create()
*/
protected static $_constraints;
 
/**
* Database of the table
* @var Database|string
* @see Table::create()
*/
protected static $_database;
 
165,6 → 187,40
}
 
/**
* Returns the <var>options</var> array for {@link Database::createTable}
*
* Should be called and overridden by inheriting classes.
*
* @return array
*/
protected function _createOptions ()
{
$options = array();
 
foreach (array('indexes', 'constraints') as $option)
{
if ($class::${"_$option"})
{
$options[$option] = $class::${"_$option"};
}
}
 
return $options;
}
 
/**
* Creates the table for this model
*
* @return bool
*/
public function create ()
{
$class = \get_class($this);
return $this->database->createTable(
$class::$_name, $class::$_columns, $this->_createOptions());
}
 
/**
* Initiates a transaction
*
* @return bool