const EXPORT_NONE = 0;
const EXPORT_TABLES = 1;
const EXPORT_CONSTRAINTS = 2;
- const EXPORT_PLUGINS = 4;
const EXPORT_ALL = 7;
+
const HYDRATE_RECORD = 2;
const HYDRATE_ARRAY = 3;
} else {
$sql[] = $query;
}
-
- if ($table->getAttribute(IPF_ORM::ATTR_EXPORT) & IPF_ORM::EXPORT_PLUGINS) {
- $sql = array_merge($sql, $this->exportGeneratorsSql($table));
- }
-
+
$sql = array_unique($sql);
rsort($sql);
return $sql;
}
- public function getAllGenerators(IPF_ORM_Table $table)
- {
- $generators = array();
-
- foreach ($table->getGenerators() as $name => $generator) {
- if ($generator === null) {
- continue;
- }
-
- $generators[] = $generator;
-
- $generatorTable = $generator->getTable();
-
- if ($generatorTable instanceof IPF_ORM_Table) {
- $generators = array_merge($generators, $this->getAllGenerators($generatorTable));
- }
- }
-
- return $generators;
- }
-
- public function exportGeneratorsSql(IPF_ORM_Table $table)
- {
- $sql = array();
-
- foreach ($this->getAllGenerators($table) as $name => $generator) {
- $table = $generator->getTable();
-
- // Make sure plugin has a valid table
- if ($table instanceof IPF_ORM_Table) {
- $data = $this->getExportableFormat($table);
- $query = $this->createTableSql($data['tableName'], $data['columns'], $data['options']);
-
- $sql = array_merge($sql, (array) $query);
- }
- }
-
- return $sql;
- }
-
private function getExportableFormat($table)
{
$columns = array();
}
}
- public function loadGenerator(IPF_ORM_Record_Generator $generator)
- {
- $generator->initialize($this->_table);
- $this->_table->addGenerator($generator, get_class($generator));
- }
-
public function check($constraint, $name = null)
{
if (is_array($constraint)) {
protected $_parser;
protected $_templates = array();
- protected $_generators = array();
protected $_invokedMethods = array();
public $listeners = array();
$tpl->setTableDefinition($this);
}
- public function getGenerators()
- {
- return $this->_generators;
- }
-
- public function getGenerator($generator)
- {
- if ( ! isset($this->_generators[$generator])) {
- throw new IPF_ORM_Exception('Generator ' . $generator . ' not loaded');
- }
-
- return $this->_generators[$generator];
- }
-
- public function hasGenerator($generator)
- {
- return isset($this->_generators[$generator]);
- }
-
- public function addGenerator(IPF_ORM_Record_Generator $generator, $name = null)
- {
- if ($name === null) {
- $this->_generators[] = $generator;
- } else {
- $this->_generators[$name] = $generator;
- }
- return $this;
- }
-
public function bindQueryParts(array $queryParts)
{
$this->_options['queryParts'] = $queryParts;