berlindb / core

All of the required core code
MIT License
253 stars 27 forks source link

Add methods to clone/copy an entire database table #38

Closed JJJ closed 2 years ago

JJJ commented 4 years ago

Just as the title says, the Table class currently lacks any method(s) related to taking all of the data in the current table and copying it (temporarily or permanently) to another table/location.

JJJ commented 4 years ago

Turns out that clone is still a reserved keyword in versions of PHP less than 7. 😞

That means PHP versions like 5.6 will complain about the clone() method.

Going to keep the code as is for now, but noting it in case anyone else gets caught with T_CLONE PHP fatal errors. Here's one from Sugar Calendar:

PHP Parse error:  syntax error, unexpected 'clone' (T_CLONE), expecting identifier (T_STRING) in /app/public/content/plugins/sugar-calendar/sugar-event-calendar/includes/classes/database/engine/class-table.php on line 490
spencerfinnell commented 2 years ago

@JJJ Do you have any thoughts about adding the fix from https://github.com/awesomemotive/sugarcalendar-core/issues/105 to the library directly? When managing BerlinDB with Composer and using PHP 5.6 (which isn't explicitly not supported) the clone method needs to be renamed after each install.

JJJ commented 2 years ago

@spencerfinnell Probably worth porting that fix here and removing it when 5.6 support gets dropped?

spencerfinnell commented 2 years ago

@JJJ I think that makes the most sense. I'm 100% certain I'm going to forget to edit it one day and break 5.6 compatibility accidentally :(