We're using Eloquent without Laravel (long story) for an app we're working on and everything is going fine but we've hit a small snag when trying to dynamically create tables from within the app.
The app is basically a ticket tracking and management system and each upon submission of the user-end form an entry is made in our tickets
table with a field of uuid
. This field corresponds to a table with the name of that same uuid ( f46ffeec091c4b9d9f406d65a50ab9e6
, for example). That table in the database that has more complete details and more fields relating to the ticket.
I've tried a LOT of different variations now but anytime I try to run something like
Capsule::query("CREATE TABLE `$uuid` LIKE `tickettable`");
We get a successful return (well- no errors, at least) but the table doesn't actually get created. We've tried with defined class names instead of Capsule
, using Schema
, running it within another class ( ClassName::query(...);
), $table = new Class(); $table->query(...);
$table = new Class(); $table->query(...);
... Nothing seems to be working.
Running something like Schema::create($uuid, function(Blueprint $table){...});
completely fails.
Running Capsule
seems to be the closest to working but still no dice. Any thoughts?
Use this:
Capsule::schema()->create($uuid, function(Blueprint $table) {
[...]
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.