Created
March 29, 2010 15:19
-
-
Save tanordheim/347945 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChildModelOne extends ParentModel { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChildModelTwo extends ParentModel { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rig up Doctrine auto loader | |
spl_autoload_register(array("Doctrine", "autoload")); | |
spl_autoload_register(array("Doctrine_Core", "modelsAutoload")); | |
// Instantiate a manager instance and connection | |
$_DOCTRINE_MANAGER = Doctrine_Manager::getInstance(); | |
$_DOCTRINE_CONNECTION = Doctrine_Manager::connection("mysql://" . DB_USER . ":" . DB_PASS . "@" . DB_HOST . "/" . DB_NAME); | |
// Configure Doctrine | |
$_DOCTRINE_MANAGER->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL); | |
$_DOCTRINE_MANAGER->setAttribute(Doctrine_Core::ATTR_EXPORT, Doctrine_Core::EXPORT_ALL); | |
$_DOCTRINE_MANAGER->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE); | |
$_DOCTRINE_MANAGER->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, true); | |
$_DOCTRINE_MANAGER->setAttribute(Doctrine_Core::ATTR_AUTOLOAD_TABLE_CLASSES, true); | |
// Enable model auto loading | |
Doctrine_Core::loadModels(APP_DIR . "/models"); | |
// Generate a YAML schema of the models | |
Doctrine_Core::generateYamlFromModels(APP_DIR . "/schema/schema.yml", APP_DIR . "/models"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ParentModel extends Doctrine_Record { | |
public function setTableDefinition() { | |
$this->hasColumn("test", "integer"); | |
$this->setSubclasses(array( | |
"ChildModelOne" => array("type" => 1), | |
"ChildModelTwo" => array("type" => 2) | |
)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parent: | |
connection: 0 | |
tableName: parent | |
columns: | |
id: | |
type: integer(8) | |
autoincrement: true | |
primary: true | |
test: integer(8) | |
ChildModelOne: | |
connection: 0 | |
tableName: child_model_one | |
columns: | |
id: | |
type: integer(8) | |
autoincrement: true | |
primary: true | |
test: integer(8) | |
ChildModelTwo: | |
connection: 0 | |
tableName: child_model_two | |
columns: | |
id: | |
type: integer(8) | |
primary: true | |
test: integer(8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment