Page 1 of 1

Restore a PHP procedure from a backup

Posted: Tue Apr 18, 2023 8:06 am
by kknm
Is it possible to restore a PHP procedure from a backup without affecting the main database?
If yes, then in what way.

When editing a PHP procedure, I mixed up the source and destination of two procedures, as a result, I corrupted the source, which I cannot restore from memory. This happened due to the fact that the ACE-editor header does not contain the name of the module being edited, which is unfortunate.

Re: Restore a PHP procedure from a backup

Posted: Tue Apr 18, 2023 8:18 am
by kev1n
Manually extract and insert the specific row: MySQL dumps are plain text files that contain SQL statements. You can open the dump file using a text editor, locate the specific row you want to restore, and extract the relevant SQL statement(s) that insert that row into the database. You can then execute that SQL statement using a MySQL client (phpMyAdmin) to insert the row directly into the database, without affecting other rows.

Re: Restore a PHP procedure from a backup

Posted: Tue Apr 18, 2023 9:04 am
by kev1n
Open the Procedure and retrieve its Id via Options Menu -> Form Info -> Record Id

Open the dump file in a text editor and search for the Id (e.g 60f8e2ea4d13aff)

You'll find a statement that looks like this:

Code: Select all

INSERT INTO `zzzzsys_php` VALUES ('60f8e2ea4d13aff','NUIMPORTUSERS','Import users from a CSV file','nubuilder','$file = nuGetProperty(\'NUIMPORTUSERS_file\');\n$delimiter = nuGetProperty(\'NUIMPORTUSERS_delimiter\');\n\nnuImportUsersFromCSV(\"../temp/\".$file, $delimiter, \"\\n\");\nnuProcessImportedUsers();','window',NULL,'1','0','',NULL);

Replace "INSERT INTO" with "REPLACE INTO"

Run the SQL in e.g. phpMyAdmin

Re: Restore a PHP procedure from a backup

Posted: Tue Apr 18, 2023 10:13 am
by kknm
Thanks, it helped