Fix: column name should not be an numeric

This commit is contained in:
Laurent Destailleur 2014-10-03 03:12:39 +02:00
parent 6a570222cc
commit c69565fd69
3 changed files with 15 additions and 16 deletions

View File

@ -2120,11 +2120,11 @@ abstract class CommonObject
foreach ($tab as $key => $value) foreach ($tab as $key => $value)
{ {
// Test fetch_array ! is_int($key) because fetch_array seult is a mix table with Key as alpha and Key as int (depend db engine) // Test fetch_array ! is_int($key) because fetch_array result is a mix table with some key as alpha and some key as int (depend db engine)
if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key)) if ($key != 'rowid' && $key != 'tms' && ! is_int($key))
{ {
// we can add this attribute to adherent object // we can add this attribute to object properties
$this->array_options["options_$key"]=$value; $this->array_options["options_".$key]=$value;
} }
} }
} }

View File

@ -154,7 +154,7 @@ class ExtraFields
{ {
$table=$elementtype.'_extrafields'; $table=$elementtype.'_extrafields';
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname))
{ {
if ($type=='boolean') { if ($type=='boolean') {
$typedb='int'; $typedb='int';
@ -226,8 +226,7 @@ class ExtraFields
// Clean parameters // Clean parameters
if (empty($pos)) $pos=0; if (empty($pos)) $pos=0;
if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname))
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
{ {
if(is_array($param) and count($param) > 0) if(is_array($param) and count($param) > 0)
{ {