From ab3e1631f4856a71a1ee2dcaf20a470d4644368e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 28 Jul 2015 11:20:00 +0200 Subject: [PATCH 1/2] FIX : php_build_class_from_table comma ending on insert --- dev/skeletons/build_class_from_table.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dev/skeletons/build_class_from_table.php b/dev/skeletons/build_class_from_table.php index e83b9e2debf..43f29a17ad3 100755 --- a/dev/skeletons/build_class_from_table.php +++ b/dev/skeletons/build_class_from_table.php @@ -227,6 +227,13 @@ foreach($property as $key => $prop) $targetcontent=preg_replace('/if \(isset\(\$this->prop1\)\) {((\n|\r|\t)*)\$this->prop1 = trim\(\$this->prop1\);((\n|\r|\t)*)}/', $varprop, $targetcontent); $targetcontent=preg_replace('/if \(isset\(\$this->prop2\)\) {((\n|\r|\t)*)\$this->prop2 = trim\(\$this->prop2\);((\n|\r|\t)*)}/', '', $targetcontent); + +$no_output_field=0; +foreach($property as $key => $prop) +{ + if ($prop['field'] == 'tms') $no_output_field++; // This is a field of type timestamp edited automatically + if ($prop['extra'] == 'auto_increment') $no_output_field++; +} // Substitute insert into parameters $varprop="\n"; $cleanparam=''; @@ -241,7 +248,7 @@ foreach($property as $key => $prop) if ($addfield) { $varprop.="\t\t\$sql.= '".$prop['field']; - if ($i < count($property)) $varprop.=","; + if ($i <= count($property)-$no_output_field) $varprop.=","; $varprop.="';"; $varprop.="\n"; } @@ -255,12 +262,7 @@ $cleanparam=''; $i=0; //Count nb field to output to manage commat at end SQL instruction -$no_output_field=0; -foreach($property as $key => $prop) -{ - if ($prop['field'] == 'tms') $no_output_field++; // This is a field of type timestamp edited automatically - if ($prop['extra'] == 'auto_increment') $no_output_field++; -} + foreach($property as $key => $prop) { @@ -307,6 +309,7 @@ foreach($property as $key => $prop) $varprop.='.\').'; } + if ($i < (count($property)-$no_output_field)) $varprop.=".','"; $varprop.=';'; $varprop.="\n"; From 938be9bae0dab49924fddbc891d44c9143b4f86b Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 28 Jul 2015 11:38:01 +0200 Subject: [PATCH 2/2] FIX : fetchAll method in skeleton.class.php --- dev/skeletons/skeleton_class.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/skeletons/skeleton_class.class.php b/dev/skeletons/skeleton_class.class.php index 72ee07c259d..83938b158e7 100644 --- a/dev/skeletons/skeleton_class.class.php +++ b/dev/skeletons/skeleton_class.class.php @@ -234,7 +234,7 @@ class Skeleton_Class extends CommonObject $sql .= ' t.field1,'; $sql .= ' t.field2'; //... - $sql .= ' FROM ' . MAIN_DB_PREFIX . 'mytable as t'; + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; // Manage filter $sqlwhere = array();