Copying database records from one table to another
3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 28, 2015 (RSS)
Hi Dave,
I am following up from the post https://www.interactivetools.com/forum/forum-posts.php?postNum=2232571 on how to copy over records from one table to another.
I tried it but I am getting the error message:
Inserting record #1
_mysql_getMysqlSetValues: Invalid column name 'floor_level:label'!
In the Section Editor, I created a new editor by copying an existing section and then ran the import described in postNum 2232571.
The column 'floor_level' is a pulldown list with the following values:
GF|Ground Floor
1stF|1st Floor
2ndF|2nd Floor
Is there a simple way around this?
Thanks
Terry
By Dave - October 28, 2015
Hi Terry,
There's no built in support for that.
But to not generate the :label, etc fields you can add this option to getRecords:
'loadPseudoFields' => false,
'loadCreatedBy' => false, // also add this to not export createdBy.* fields
'loadUploads' => false, // and to not output upload data (which won't get copied anyways)
And here's a way to copy an entire table:
- Go to: Admin > General > Backup & Restore
- Backup your entire database for safety (select: All Database Table)
- Now, backup the table you want to copy, eg: example1
- Find the backup file, eg: cmsb/data/backups/hostname-v2.##-20151022-145723-example1.sql.php
- Rename it from "example1" to "example2"
- Open the file and replace #TABLE_PREFIX#_example1 to #TABLE_PREFIX#_example2
- Restore the renamed backup file under: Admin > General
Hope that helps! Good luck!
interactivetools.com
Hi Dave,
I like the second option much better and it worked absolutely perfectly!
Thanks very much.
Best regards
Terry