dimanche 23 juin 2019

How to create tables in raw query laravel?

I'm trying to create new DB, which is created successfully, and some tables in that DB, table is not created. Whats wrong with this query? It says:

QueryException in Connection.php line 770: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CREATE TABLE activities ( id int(10) UNSIGNED NOT NULL, ' at line 3 (SQL: CREATE DATABASE institution_70 CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE TABLE activities ( id int(10) UNSIGNED NOT NULL, name varchar(150) COLLATE utf8_unicode_ci NOT NULL, created_at timestamp NULL DEFAULT NULL, updated_at timestamp NULL DEFAULT NULL, deleted_at timestamp NULL DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; )

DB::connection('rc')->statement("
    CREATE DATABASE institution_$institutionId CHARACTER SET utf8 COLLATE utf8_general_ci;

    CREATE TABLE `activities` (
      `id` int(10) UNSIGNED NOT NULL,
      `name` varchar(150) COLLATE utf8_unicode_ci NOT NULL,
      `created_at` timestamp NULL DEFAULT NULL,
      `updated_at` timestamp NULL DEFAULT NULL,
      `deleted_at` timestamp NULL DEFAULT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
    ");



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/31OLOz4
via IFTTT

Aucun commentaire:

Enregistrer un commentaire