Skip to content

Commit

Permalink
Merge pull request #3328 from FHenry/3.8
Browse files Browse the repository at this point in the history
FIX : php_build_class_from_table.php comma ending on insert
  • Loading branch information
eldy committed Jul 28, 2015
2 parents 747e4b5 + 938be9b commit 22c68a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions dev/skeletons/build_class_from_table.php
Expand Up @@ -227,6 +227,13 @@
$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='';
Expand All @@ -241,7 +248,7 @@
if ($addfield)
{
$varprop.="\t\t\$sql.= '".$prop['field'];
if ($i < count($property)) $varprop.=",";
if ($i <= count($property)-$no_output_field) $varprop.=",";
$varprop.="';";
$varprop.="\n";
}
Expand All @@ -255,12 +262,7 @@
$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)
{
Expand Down Expand Up @@ -307,6 +309,7 @@
$varprop.='.\').';

}

if ($i < (count($property)-$no_output_field)) $varprop.=".','";
$varprop.=';';
$varprop.="\n";
Expand Down
2 changes: 1 addition & 1 deletion dev/skeletons/skeleton_class.class.php
Expand Up @@ -234,7 +234,7 @@ public function fetchAll($sortorder, $sortfield, $limit, $offset, array $filter
$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();
Expand Down

0 comments on commit 22c68a3

Please sign in to comment.