diff --git a/dev/SQL/index.php b/dev/SQL/index.php new file mode 100644 index 000000000..e3c24d2b9 --- /dev/null +++ b/dev/SQL/index.php @@ -0,0 +1,82 @@ +row=20; +$acc=new Database(); + +$a_dossier=$acc->make_array("select dos_id,dos_id::text||' '||dos_name from ac_dossier order by dos_id"); +$a_dossier[]=array('value'=>0,'label'=>'Account_Repository'); +$select->value=$a_dossier; +$select->selected = $gDossier; + +////////////////////////////////////////////////////////////////////////////// +// If no db is selected then propose one +////////////////////////////////////////////////////////////////////////////// +if ($gDossier==-1) { +?> +
+row=20; +$select_table->value=$cn->make_array($table_sql); +$select_table->selected = HtmlInput::default_value_request("table", ""); +?> + +create_class(); + echo ''; + $table_sql->send(); + echo ''; +} + +?> diff --git a/dev/SQL/table_sql.class.php b/dev/SQL/table_sql.class.php new file mode 100644 index 000000000..19ac2cc10 --- /dev/null +++ b/dev/SQL/table_sql.class.php @@ -0,0 +1,61 @@ +schema_name,$this->table_name)= explode(",",$p_schematable); + $this->db=$cn; + } + /** + * Must create a Object to handle the SQL object + */ + function create_class() + { + $this->script=""; + $columns=$this->db->get_array(" + select column_name,data_type,is_nullable from information_schema.columns + where + table_name=$1 + and + table_schema=$2 order by ordinal_position", + array($this->table_name,$this->schema_name) + ); + $apk=$this->db->get_array(" + select column_name from information_schema.constraint_column_usage where constraint_name = (select constraint_name from +information_schema.table_constraints + where + table_name = $1 + and table_schema=$2 + and constraint_type='PRIMARY KEY') +; +" + ,array($this->table_name,$this->schema_name)); + if ( count($apk) > 1 ) { + $this->pk="pk composé"; + } else { + $this->pk=$apk[0]['column_name']; + } + ob_start(); + include 'template/script_sql.php'; + $this->script= ob_get_contents(); + ob_clean(); + } + function send() + { + echo $this->script; + } +} diff --git a/dev/SQL/template/script_sql.php b/dev/SQL/template/script_sql.php new file mode 100644 index 000000000..3979fb08e --- /dev/null +++ b/dev/SQL/template/script_sql.php @@ -0,0 +1,65 @@ + + +/** + * Autogenerated file + */ +/** + * table_name."_sql.class.php"."\n"; ?> + * + *@file + *@brief abstract of the table schema_name.".".$this->table_name?> + */ +class table_name)."_SQL";?> extends SQL +{ + +function __construct($p_id=-1) + { + $this->table = "schema_name.".".$this->table_name?>"; + $this->primary_key = "pk?>"; +/* + * List of columns + */ + $this->name=array( + '.'"'.$columns[$i]['column_name'].'"'; + $sep=","; + printf("\n"); + endfor; +?> + ); +/* + * Type of columns + */ + $this->type = array( + '.'"'.$type.'"'; + printf("\n"); + $sep=","; + endfor; +?> ); + + + $this->default = array( + "pk?>" => "auto", + ); + + $this->date_format = "DD.MM.YYYY"; + global $cn; + + parent::__construct($cn,$p_id); + } + + +} \ No newline at end of file