Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Give nuBuilder the ability to manage legacy data bases.

cypherinfo
Posts: 125
Joined: Thu Feb 18, 2010 5:42 pm
Contact:

Give nuBuilder the ability to manage legacy data bases.

Unread post by cypherinfo »

Hello,


from the topic: "Lookup Object Works But In The Edit Screen!" http://forums.nubuilder.cloud/viewtopic.php?f=4&t=2256 I notice that the key factor you used to develop nuBuilder is bind around the initial hypothesis that the table to be linked to its interface is empty or have to be nuBuilderi(zed) in order to be managed with its interface.

I mean if the legacy table has its primary key autoincrement or timestamp type field, that table in order to be used with nuBuilder has to be modified. It has to added another field used as primary key in order nuBuilder can works. More if the form linked to that table contains a lookup object, another field is needed to be present in the table for the foreign key to the lookup table.

I wonder: in order to make nuBuilder a more comprensive web interface able to manage legacy data base too, why not to enrich it with the capability to work as interface for legacy data bases?

P.S.: I have to nuBuilder(ized) a legacy table; I mean I have added a field to use as primary key for nuBuilder (varchar(15)). Now it is needed to add for every empty field the value to be used as primary key.
I wonder how to do the mandatory instructions as stated here: http://wiki.nubuilder.com/tiki-index.ph ... uilderDocs ?


Thank you.




Cypherinfo.
jlcsusara
Posts: 23
Joined: Wed Apr 07, 2010 10:32 am

Re: Give nuBuilder the ability to manage legacy data bases.

Unread post by jlcsusara »

hello, cypherinfo. i'm also a new user of nuBuilder.

i managed to convert my legacy database without any problems. all my tables had a Primary Key of Integer (with Auto-increment on).

i just changed the Type to VARCHAR(15) and turned-off Auto-incrementing.

my previous id of

Code: Select all

1
became

Code: Select all

"1               "
(the character "1" followed by 14 spaces).

--Jonathan
cypherinfo
Posts: 125
Joined: Thu Feb 18, 2010 5:42 pm
Contact:

Re: Give nuBuilder the ability to manage legacy data bases.

Unread post by cypherinfo »

Hello,


I was thinking to add something on the form linked to some PHP code - I do not know what may be (I'm not a master) -

Code: Select all

do {
    mysql_query("UPDATE table SET field='{uniqid()}' WHERE field='' LIMIT 1");
} while (mysql_affected_rows());


that "something" (button or else) should have to nubuilder(ize) any not empty table one want to use with a nuBuilder interface.

May you help me to make nuBuilder compatible with all of the tables empty or not any user may want to add an interface to, please?


Thank you.



Cypherinfo.
steven
Posts: 218
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 1 time

Re: Give nuBuilder the ability to manage legacy data bases.

Unread post by steven »

Cypherinfo,

I'm not too worried about managing legacy systems. Trying to cater for the myriad of different databases and structures used would be endless.

BUT..

I have written some code that can be used to create primary keys and foreign keys in other mysql tables, (that can be used with nuBuilder).

Code: Select all

//-- create the 2 variables for each table that needs a new primary key.

$pk_table['gig']['old_pk']      = 'gig_id';
$pk_table['gig']['new_pk']      = 'nuest_customer_id';

//-- then create 2 variables for each table that will be linked by a foreign key to this table.

$pk_table['gig'][0]['fk_table'] = 'gig_artist';
$pk_table['gig'][0]['fk_field'] = 'art_gig_id';
//$pk_table['customer'][1]['fk_table'] = 'customer_group_link';
//$pk_table['customer'][1]['fk_field'] = 'cgl_customer_id';



foreach( $pk_table as $table => $value){

//--- create a new field that will become the new primary key
        $old_pk                      = $pk_table[$table]['old_pk'];
        $new_pk                      = $pk_table[$table]['new_pk'];
        nuRunQuery("ALTER TABLE `$table` ADD `$new_pk` VARCHAR(15) NOT NULL FIRST");

        for($i = 2 ; $i < count($pk_table[$table]) ; $i++){
//--- create a new field that will become the new foreign key 
//--- (it will be the same name as the current fk but prefixed with 'nu_')
            $FT                      = $pk_table[$table][$i-2]['fk_table'];
            $FF                      = $pk_table[$table][$i-2]['fk_field'];
            $update_string           = "ALTER TABLE `$FT` ADD ";
            $update_string          .= "`nu_$FF` VARCHAR(15) NOT NULL ;";
            nuRunQuery($update_string);
        }

        $t                           = nuRunQuery("SELECT `$old_pk` FROM $table ORDER BY `$old_pk`");
        while($r                     = db_fetch_row($t)){
            $new_id                  = uniqid('1');
            $old_id                  = $r[0];
            $update_string           = "UPDATE `$table` SET `$new_pk` = '$new_id' ";
            $update_string          .= "WHERE `$old_pk` = '$old_id'";
            nuRunQuery($update_string);
            for($i = 2 ; $i < count($pk_table[$table]) ; $i++){
                $FT                  = $pk_table[$table][$i-2]['fk_table'];
                $FF                  = $pk_table[$table][$i-2]['fk_field'];
                $update_string       = "UPDATE `$FT` SET `nu_$FF` = '$new_id' ";
                $update_string      .= "WHERE `$FF` = '$old_id'";
                nuRunQuery($update_string);
            }

        }
}


You'll still need to change some field names and indexes but it should make things a lot easier.


Steven
If you like nuBuilder, how about leaving a nice review on SourceForge?
cypherinfo
Posts: 125
Joined: Thu Feb 18, 2010 5:42 pm
Contact:

Re: Give nuBuilder the ability to manage legacy data bases.

Unread post by cypherinfo »

Hello,

I keep on wondering where to add that?

:-)

Thank you.



Cypherinfo.
steven
Posts: 218
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 1 time

Re: Give nuBuilder the ability to manage legacy data bases.

Unread post by steven »

Cyhperinfo,

The best place to put it, is in a procedure.

Its basically works the same way as a report, except that its job isn't to display something (just to run php).
It will just give you a blank html page when its finished, although you can echo stuff out to this page if you want.

Steven
If you like nuBuilder, how about leaving a nice review on SourceForge?
cypherinfo
Posts: 125
Joined: Thu Feb 18, 2010 5:42 pm
Contact:

Re: Give nuBuilder the ability to manage legacy data bases.

Unread post by cypherinfo »

Hello,


having seen the importance of that matter for many potential nuBuilder users, I wonder if you consider useful to realize - it lacks in the video tutorial list - a video tutorial about adding an activity for a PHP procedure about this thread: nuBuilder(ize) a user legacy table. I'm willing to give you the table to implement for the tutorial in order make it compatible to nuBuilder.

What a great quantum leap should be for nuBuilder!


Thank you.



Cypherinfo.
steven
Posts: 218
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 1 time

Re: Give nuBuilder the ability to manage legacy data bases.

Unread post by steven »

Cypherinfo,

If you mean Procedures in general..
It seems that the Add Activities button could have been explained a bit more comprehensively.
BTW what app do you use to capture video and can you add sound to it?

If you mean this PHP code...
Although it can be helpful, this code is not specifically just for nuBuilder, and as nuBuilder is a essentially a GUI.
To make a video to explain how to write the code, might not make sense.

Steven
If you like nuBuilder, how about leaving a nice review on SourceForge?
steven
Posts: 218
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 1 time

Re: Give nuBuilder the ability to manage legacy data bases.

Unread post by steven »

I've now added an explanation to the wiki.
http://wiki.nubuilder.com/tiki-index.ph ... Activities

Steven
If you like nuBuilder, how about leaving a nice review on SourceForge?
cypherinfo
Posts: 125
Joined: Thu Feb 18, 2010 5:42 pm
Contact:

Re: Give nuBuilder the ability to manage legacy data bases.

Unread post by cypherinfo »

Hello,


well, coming from education with your video tutorials I know something similar is explained in the Reports tutorial: http://wiki.nubuilder.com/tiki-index.ph ... uilderDocs.

When, I encountered nuBuilder for the first time I was dreaming about a tool to build interfaces on any kind of Mysql data bases: legacy or not; from the scratch or not; empty or not.

With some code addition that is now possible and it would be great if you add a video tutorial about adding a legacy table to make compatible with nuBuilder in the list of your tutorial in order to meet the needs of not so skilled user too that want to simply use their already existing tables.

I mean for the first time user, in order to fully understand the path to learn how to nuBuilder(ize) his/her tables he/she has to read all of the threads in this forum, when should be more straight and easy to watch it one of your tutorial. It should be clear soon that nuBuilder is able to manage legacy tables too from the turorial list, instead of randomnly find it in a forum thread!


Thank you.



Cypherinfo.
Locked