2
0
forked from Wavyzz/dolibarr

Add function DDLUpdateField

This commit is contained in:
Laurent Destailleur
2011-03-08 10:33:43 +00:00
parent 05c4533b5b
commit 01c102f66a
4 changed files with 78 additions and 0 deletions

View File

@@ -911,6 +911,25 @@ class DoliDb
return 1;
}
/**
* Update format of a field into a table
* @param table Name of table
* @param field_name Name of field to modify
* @param field_desc Array with description of field format
* @return int <0 if KO, >0 if OK
*/
function DDLUpdateField($table,$field_name,$field_desc)
{
$sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table;
$sql .= " MODIFY COLUMN ".$field_name." ".$field_desc['type'];
if ($field_desc['type'] == 'int' || $field_desc['type'] == 'varchar') $sql.="(".$field_desc['value'].")";
dol_syslog($sql,LOG_DEBUG);
if (! $this->query($sql))
return -1;
else
return 1;
}
/**
* \brief Drop a field in table

View File

@@ -974,6 +974,26 @@ class DoliDb
return 1;
}
/**
* Update format of a field into a table
* @param table Name of table
* @param field_name Name of field to modify
* @param field_desc Array with description of field format
* @return int <0 if KO, >0 if OK
*/
function DDLUpdateField($table,$field_name,$field_desc)
{
$sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table;
$sql .= " MODIFY COLUMN ".$field_name." ".$field_desc['type'];
if ($field_desc['type'] == 'int' || $field_desc['type'] == 'varchar') $sql.="(".$field_desc['value'].")";
dol_syslog($sql,LOG_DEBUG);
if (! $this->query($sql))
return -1;
else
return 1;
}
/**
* \brief Drop a field in table
* \param table Nom de la table

View File

@@ -986,6 +986,25 @@ class DoliDb
return 1;
}
/**
* Update format of a field into a table
* @param table Name of table
* @param field_name Name of field to modify
* @param field_desc Array with description of field format
* @return int <0 if KO, >0 if OK
*/
function DDLUpdateField($table,$field_name,$field_desc)
{
$sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table;
$sql .= " MODIFY COLUMN ".$field_name." ".$field_desc['type'];
if ($field_desc['type'] == 'int' || $field_desc['type'] == 'varchar') $sql.="(".$field_desc['value'].")";
dol_syslog($sql,LOG_DEBUG);
if (! $this->query($sql))
return -1;
else
return 1;
}
/**
* \brief Drop a field in table

View File

@@ -1116,6 +1116,26 @@ class DoliDb
return 1;
}
/**
* Update format of a field into a table
* @param table Name of table
* @param field_name Name of field to modify
* @param field_desc Array with description of field format
* @return int <0 if KO, >0 if OK
*/
function DDLUpdateField($table,$field_name,$field_desc)
{
$sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table;
$sql .= " MODIFY COLUMN ".$field_name." ".$field_desc['type'];
if ($field_desc['type'] == 'int' || $field_desc['type'] == 'varchar') $sql.="(".$field_desc['value'].")";
dol_syslog($sql,LOG_DEBUG);
if (! $this->query($sql))
return -1;
else
return 1;
}
/**
* \brief Drop a field in table
* \param table Nom de la table