/**
  *  Update attribute type
  *
  *	On error this method returning FALSE.
  *
  *  Possible options:
  *	 - none
  *	
  *	@param	Attr_type	$at
  *	@param	string		$old_name	Old name of attribute. If is set, attr. type is updated otherwise is created new
  *	@param	array		$opt		Array of options
  *	@return bool
  */
 function update_attr_type($at, $old_name, $opt)
 {
     global $config;
     $errors = array();
     if (!$this->connect_to_db($errors)) {
         ErrorHandler::add_error($errors);
         return false;
     }
     /* table's name */
     $t_name =& $config->data_sql->attr_types->table_name;
     /* col names */
     $c =& $config->data_sql->attr_types->cols;
     if (is_null($old_name)) {
         $q = "insert into " . $t_name . "(\n\t\t\t             " . $c->name . ", \n\t\t\t\t\t\t " . $c->rich_type . ", \n\t\t\t\t\t\t " . $c->raw_type . ", \n\t\t\t\t\t\t " . $c->type_spec . ", \n\t\t\t\t\t\t " . $c->desc . ", \n\t\t\t\t\t\t " . $c->default_flags . ", \n\t\t\t\t\t\t " . $c->flags . ", \n\t\t\t\t\t\t " . $c->priority . ", \n\t\t\t\t\t\t " . $c->access . ", \n\t\t\t\t\t\t " . $c->group . ", \n\t\t\t\t\t\t " . $c->order . ")\n\t\t\t      values (" . $this->sql_format($at->get_name(), "s") . ", \n\t\t\t\t          " . $this->sql_format($at->get_type(), "s") . ", \n\t\t\t\t\t\t  " . $this->sql_format($at->get_raw_type(), "n") . ", \n\t\t\t\t\t\t  " . $this->sql_format(serialize($at->get_type_spec()), "s") . ", \n\t\t\t\t\t\t  " . $this->sql_format($at->get_raw_description(), "s") . ", \n\t\t\t\t\t\t  " . $this->sql_format($at->get_default_flags(), "n") . ", \n\t\t\t\t\t\t  " . $this->sql_format($at->get_flags(), "n") . ", \n\t\t\t\t\t\t  " . $this->sql_format($at->get_priority(), "n") . ", \n\t\t\t\t\t\t  " . $this->sql_format($at->get_access(), "n") . ", \n\t\t\t\t\t\t  " . $this->sql_format($at->get_group(), "s") . ", \n\t\t\t\t\t\t  " . $this->sql_format($at->get_order(), "n") . ")";
     } else {
         $q = "update " . $t_name . " \n\t\t\t      set " . $c->name . "          = " . $this->sql_format($at->get_name(), "s") . ",\n\t\t\t          " . $c->rich_type . "     = " . $this->sql_format($at->get_type(), "s") . ",\n\t\t\t          " . $c->raw_type . "      = " . $this->sql_format($at->get_raw_type(), "n") . ",\n\t\t\t          " . $c->type_spec . "     = " . $this->sql_format(serialize($at->get_type_spec()), "s") . ",\n\t\t\t          " . $c->desc . "          = " . $this->sql_format($at->get_raw_description(), "s") . ",\n\t\t\t          " . $c->default_flags . " = " . $this->sql_format($at->get_default_flags(), "n") . ",\n\t\t\t          " . $c->flags . "         = " . $this->sql_format($at->get_flags(), "n") . ",\n\t\t\t          " . $c->priority . "      = " . $this->sql_format($at->get_priority(), "n") . ",\n\t\t\t          " . $c->access . "        = " . $this->sql_format($at->get_access(), "n") . ",\n\t\t\t          " . $c->group . "         = " . $this->sql_format($at->get_group(), "s") . ",\n\t\t\t          " . $c->order . "         = " . $this->sql_format($at->get_order(), "n") . "\n\t\t\t      where " . $c->name . " = " . $this->sql_format($old_name, "s");
     }
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         ErrorHandler::log_errors($res);
         return false;
     }
     return true;
 }