function xanth_install_db()
{
    //install core db
    require_once './engine/install.inc.php';
    xanth_db_start_transaction();
    xanth_db_install_core();
    $weighted_components = array();
    foreach (xComponent::find_existing() as $component) {
        include_once $component->path . '/install.inc.php';
        $weight_func = 'xanth_db_install_weight_' . $component->name;
        $weighted_components[] = array($weight_func(), $component);
    }
    usort($weighted_components, 'weight_cmp');
    foreach ($weighted_components as $component) {
        $inst_func = 'xanth_db_install_' . $component[1]->name;
        $inst_func();
    }
    $weighted_modules = array();
    foreach (xModule::find_existing() as $module) {
        include_once $module->path . '/install.inc.php';
        $weight_func = 'xanth_db_install_weight_' . $module->name;
        $weighted_modules[] = array($weight_func(), $module);
    }
    usort($weighted_modules, 'weight_cmp');
    foreach ($weighted_modules as $module) {
        $inst_func = 'xanth_db_install_' . $module[1]->name;
        $inst_func();
    }
    xanth_db_commit();
}
 /**
  *
  */
 function insert()
 {
     xanth_db_start_transaction();
     $field_names = "title,description";
     $field_values = "'%s','%s'";
     $values = array($this->title, $this->description);
     if (!empty($this->view_mode_id)) {
         $field_names .= ",view_mode_id";
         $field_values .= ",'%d'";
         $values[] = $this->view_mode_id;
     }
     if (!empty($this->parent_id)) {
         $field_names .= ",parent_id";
         $field_values .= ",'%d'";
         $values[] = $this->parent_id;
     }
     xanth_db_query("INSERT INTO category ({$field_names}) VALUES ({$field_values})", $values);
     $this->id = xanth_db_get_last_id();
     if (!empty($this->entry_type_names)) {
         foreach ($this->entry_type_names as $type) {
             xanth_db_query("INSERT INTO category_to_entry_type (cat_id,entry_type) VALUES ('%s','%s')", $this->id, $type);
         }
     }
     xanth_db_commit();
 }
 function update()
 {
     xanth_db_start_transaction();
     //delete old visual elements
     xanth_db_query("DELETE FROM theme_to_elements WHERE theme_name = '%s'", $this->name);
     //now reinsert
     foreach ($this->themed_elements as $element => $view) {
         xanth_db_query("INSERT INTO theme_to_elements(theme_name,visual_element,view_mode) VALUES ('%s','%s','%s')", $this->name, $element, $view);
     }
     xanth_db_commit();
 }
 /**
  *
  */
 function find_all()
 {
     xanth_db_start_transaction();
     $entries = array();
     $result = xanth_db_query("SELECT * FROM entry");
     for ($i = 0; $row = xanth_db_fetch_object($result); $i++) {
         $entries[$i] = new xEntry($row->id, $row->title, $row->type, $row->author, $row->content, $row->content_format, $row->published, $row->description, $row->keywords, array(), xanth_db_decode_timestamp($row->creation_time));
         $result2 = xanth_db_query("SELECT * FROM categorytoentry,category WHERE entryId = %d AND category.id = catId", $row->id);
         $categories = array();
         while ($row = xanth_db_fetch_object($result2)) {
             $categories[] = new xCategory($row->id, $row->title, $row->parent_id);
         }
         $entry[$i]->categories = $categories;
     }
     xanth_db_commit();
     return $entries;
 }