Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

my FastForm builder seems to be dropping tables...

Questions related to using nuBuilder Forte.
lxnunes
Posts: 22
Joined: Sat Dec 18, 2021 1:40 am
Has thanked: 2 times

my FastForm builder seems to be dropping tables...

Unread post by lxnunes »

Hi!

Sorry for the dramatic tone but I just lost a table using the fastForm builder in the most recent version.

I had previously a version dating 22 Dec and updated to the most recent one (using a git merge, followed by the update procedure from within nuBase). When creating a FastForm to show the contents of an existing table (1st image), once I hit the "create" button, I receive an error message and by then, the table was deleted (confirmed by using phpmyadmin).
droptbl-01.PNG
droptbl-02.PNG
In my previous version I noticed errors in nuDebug, stating the table could not be created, but the form was still created. Now the error message is very much visible but the process stops and the table is dropped...

Can you replicate this behaviour? Or is this just a messed-up update at my end?

Thank you in advance for checking this.
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: my FastForm builder seems to be dropping tables...

Unread post by kev1n »

Did you run the SQL in phpMyAdmin to get more details on the error?
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: my FastForm builder seems to be dropping tables...

Unread post by kev1n »

Ok, I see that the error says that the table already exists. Did you manually create the table before?
lxnunes
Posts: 22
Joined: Sat Dec 18, 2021 1:40 am
Has thanked: 2 times

Re: my FastForm builder seems to be dropping tables...

Unread post by lxnunes »

Hi! The table already existed, and the FF builder was "aware" of the fact because as the 1st image shows, the table columns were all there.

To give you the full story, a few days ago, I created a browse&edit form to present this particular table's data and today I wanted to create a 2nd browse&edit form that would show different columns.

In my 1st form, I saw the error message in nuDebug about the table already existing, but since the form was created, I did not pay much attention to it, assuming it was just an informational message. However today, when adding the 2nd form for this table, the error message was as you see on the 2nd picture and the table disappeared.

I thought we could run the fastform builder over existing tables, couldn't we?
lxnunes
Posts: 22
Joined: Sat Dec 18, 2021 1:40 am
Has thanked: 2 times

Re: my FastForm builder seems to be dropping tables...

Unread post by lxnunes »

I have just recreated my table form a backup and ran the FF process again but this time logging mysql. There is indeed a Create followed by a Drop table (see attachment).
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: my FastForm builder seems to be dropping tables...

Unread post by kev1n »

lxnunes wrote: Tue Jan 04, 2022 5:29 pm
I thought we could run the fastform builder over existing tables, couldn't we?
Yes, absolutely. The Form Builder checks whether a table exists and only if it does not, it is created.
For some unknown reason, this check does not seem to work reliably for you.

As a quick fix, comment out line 189 in nubuilders.php

Code: Select all

// nuRunQuery("DROP TABLE IF EXISTS `$table`;"); 
lxnunes
Posts: 22
Joined: Sat Dec 18, 2021 1:40 am
Has thanked: 2 times

Re: my FastForm builder seems to be dropping tables...

Unread post by lxnunes »

OK, thak you for the help! I will reinstall a fresh copy of the nubuilder files tonight and let you know if it sorted out the issue.
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: my FastForm builder seems to be dropping tables...

Unread post by kev1n »

You can just exclude that line, no need to do a fresh installation.
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: my FastForm builder seems to be dropping tables...

Unread post by kev1n »

Could you try something? Replace the function nuFFIsNewTable() in nubuilders.php with this one:

Code: Select all

function nuFFIsNewTable($table, &$PK, $formType) {

	if ($formType == 'launch') return false;

	$t								= nuRunQuery("SELECT table_name AS 'table_name' FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = DATABASE()");
	while($s = db_fetch_object($t)){

		if($s->table_name == $table){

			$_POST['tableSchema']	= nuBuildTableSchema();
			$PK						= isset($_POST['tableSchema'][$table]['primary_key'][0]) ? $_POST['tableSchema'][$table]['primary_key'][0] : null;

			return false;

		}

	}

	return true;

}
The table_name seems to be uppercase in INFORMATION_SCHEMA and hence the "does the table exist" detection fails. This should fix it.
lxnunes
Posts: 22
Joined: Sat Dec 18, 2021 1:40 am
Has thanked: 2 times

Re: my FastForm builder seems to be dropping tables...

Unread post by lxnunes »

I was just about getting to the same conclusion in a much more blunt way. I used TABLE_NAME when getting the object but your code is more elegant :)

I now just need to figure something out. For whatever reason, the query that retrieves the table names using the DATABASE() function does not work either. It seems that this will always return the information_schema DB instead of the one I use for nuBuilder (which I called in a non-imaginative way, TestDB). As such the table is also considered always "new".

Would it be possible to feed the $nuConfigDBName to this query instead of relying in the result of DATABASE()? I am not sure what would be the behaviour if I had multiple databases...

My conclusion is that in my particular setup, the code that checks if the table is new, never actually worked because this check always failed (i.e. the tables were always seen as new). But as it was written before, it would silently continue the form creation process.
Post Reply