Fix: Removed of a column

This commit is contained in:
Laurent Destailleur 2009-01-26 23:58:37 +00:00
parent ab711a3ead
commit e817b6891b
2 changed files with 38 additions and 36 deletions

View File

@ -166,12 +166,15 @@ class AdherentOptions
}
/**
\brief fonction qui cr<EFBFBD>e un label
\param attrname nom de l'atribut
\param label nom du label
*/
* \brief Fonction qui cree un label
* \param attrname nom de l'atribut
* \param label nom du label
*/
function create_label($attrname,$label='',$type='',$pos=0,$size=0)
{
// Clean parameters
if (empty($pos)) $pos=0;
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
{
@ -192,36 +195,36 @@ class AdherentOptions
}
}
/*!
\brief fonction qui supprime un attribut
\param attrname nom de l'atribut
*/
/**
* \brief Fonction qui supprime un attribut
* \param attrname nom de l'atribut
*/
function delete($attrname)
{
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)){
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."adherent_options DROP COLUMN $attrname";
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
{
$result=$this->db->DDLDropField(MAIN_DB_PREFIX."adherent_options",$attrname);
if ($result < 0)
{
$this->error=$this->db->lasterror();
dolibarr_syslog("AdherentOption::delete ".$this->error, LOG_ERR);
}
if ( $this->db->query( $sql) )
{
return $this->delete_label($attrname);
}
else
{
print dolibarr_print_error($this->db);
return 0;
}
}else{
$result=$this->delete_label($attrname);
return $result;
}
else
{
return 0;
}
}
/*!
\brief fonction qui supprime un label
\param attrname nom du label
*/
/**
* \brief Fonction qui supprime un label
* \param attrname nom du label
*/
function delete_label($attrname)
{
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)){
@ -242,13 +245,12 @@ class AdherentOptions
}
/*!
/**
\brief fonction qui modifie un attribut optionnel
\param attrname nom de l'atribut
\param type type de l'attribut
\param length longuer de l'attribut
*/
function update($attrname,$type='varchar',$length=255)
{
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)){
@ -342,10 +344,10 @@ class AdherentOptions
{
while ($tab = $this->db->fetch_object($resql))
{
// we can add this attribute to adherent object
$array_name_label[$tab->name]=$tab->label;
$this->attribute_name[$tab->name]=$tab->type;
$this->attribute_label[$tab->name]=$tab->label;
// we can add this attribute to adherent object
$array_name_label[$tab->name]=$tab->label;
$this->attribute_name[$tab->name]=$tab->type;
$this->attribute_label[$tab->name]=$tab->label;
}
return $array_name_label;
}else{

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by