midgard_config or how to create database tables
Posted on 2007-03-13 12:04:43 EET.
Just two weeks ago I wrote about midgard_config and creating personal database. In that case I used SQLite provider and now I will try MySQL and PostgreSQL ones. If you used to switch between database types , I suggest to create few database types entries in configuration file.
Just like this:
Type=MySQL
#Type=SQLite
#Type=PostgreSQL
Comment , uncomment whenever you want. Yes, I know no one is so crazy to switch among database types every 5 minutes, but at least we have such possibility :)
I assume , you already created database and it's owner. So now it's high time to create basic tables and those ones needed for all Your MgdSchema classes.
Let's use personal "MyConfig" configuration file.
<?php
mgd_config_init("MyConfig");
$config = new midgard_config("MyConfig");
if($config->tablecreate) {
midgard_config::create_midgard_tables();
foreach($_MIDGARD['schema']['types'] as $classname => $data) {
midgard_config::create_class_table($classname);
}
}
?>
Run this script and enjoy spring morning in meantime.
The things which happen in background are sexy or jazzy. In Poland you may say "kaczi" which means "ducky". ( Because these two twins has 'duck' in their surname ) BTW, if you do not know how to recognize them , the hint is: one is president and another is prime minister.
midgard_config::create_midgard_tables
Creates tables used by Midgard itself.
- repligard
- sitegroup
- midgard_user
- imports default SG0 root with 'admin' username
midgard_config::create_class_table($classname)
Creates all tables and columns needed for class.
- If class is multilingual then language content table is also created.
- guid and sitegroup column is automagically created
- metadata columns are also automagically created
- All required indexes are also created for table.
Now, you are able to login to Midgard database. Stay tuned to learn more about "how can I login in to Midgard database?"