diff --git a/dev/skeletons/build_class_from_table.php b/dev/skeletons/build_class_from_table.php index cc6d557c58c..cae093ef89f 100755 --- a/dev/skeletons/build_class_from_table.php +++ b/dev/skeletons/build_class_from_table.php @@ -1,6 +1,6 @@ #!/usr/bin/php +/* Copyright (C) 2008-2014 Laurent Destailleur * * 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 @@ -50,12 +50,18 @@ print "***** $script_file ($version) *****\n"; // -------------------- START OF BUILD_CLASS_FROM_TABLE SCRIPT -------------------- // Check parameters -if (! isset($argv[1])) +if (! isset($argv[1]) || (isset($argv[2]) && ! isset($argv[6]))) { - print "Usage: $script_file tablename\n"; + print "Usage: $script_file tablename [server port databasename user pass]\n"; exit; } +if (isset($argv[2]) && isset($argv[3]) && isset($argv[4]) && isset($argv[5]) && isset($argv[6])) +{ + print 'Use specific database ids'."\n"; + $db=getDoliDBInstance('mysqli',$argv[2],$argv[5],$argv[6],$argv[4],$argv[3]); +} + if ($db->type != 'mysql' && $db->type != 'mysqli') { print "Error: This script works with mysql or mysqli driver only\n"; @@ -184,7 +190,7 @@ $varprop="\n"; $cleanparam=''; foreach($property as $key => $prop) { - if ($prop['field'] != 'rowid') + if ($prop['field'] != 'rowid' && $prop['field'] != 'id') { $varprop.="\tvar \$".$prop['field']; if ($prop['istime']) $varprop.="=''"; @@ -201,7 +207,7 @@ $varprop="\n"; $cleanparam=''; foreach($property as $key => $prop) { - if ($prop['field'] != 'rowid' && ! $prop['istime']) + if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) { $varprop.="\t\tif (isset(\$this->".$prop['field'].")) \$this->".$prop['field']."=trim(\$this->".$prop['field'].");"; $varprop.="\n"; @@ -283,7 +289,7 @@ $i=0; foreach($property as $key => $prop) { $i++; - if ($prop['field'] != 'rowid') + if ($prop['field'] != 'rowid' && $prop['field'] != 'id') { $varprop.="\t\t\$sql.= \" "; $varprop.=$prop['field'].'='; @@ -324,7 +330,7 @@ $i=0; foreach($property as $key => $prop) { $i++; - if ($prop['field'] != 'rowid') + if ($prop['field'] != 'rowid' && $prop['field'] != 'id') { $varprop.="\t\t\t\t\$this->".$prop['field']." = "; if ($prop['istime']) $varprop.='$this->db->jdate('; @@ -343,7 +349,7 @@ $varprop="\n"; $cleanparam=''; foreach($property as $key => $prop) { - if ($prop['field'] != 'rowid') + if ($prop['field'] != 'rowid' && $prop['field'] != 'id') { $varprop.="\t\t\$this->".$prop['field']."='';"; $varprop.="\n"; @@ -462,6 +468,6 @@ else $error++; // -------------------- END OF BUILD_CLASS_FROM_TABLE SCRIPT -------------------- -print "You can now rename generated files by removing the 'out.' prefix in their name and store them in a directory of your choice.\n"; +print "You can now rename generated files by removing the 'out.' prefix in their name and store them into directory /yourmodule/class.\n"; return $error; ?>