Laravel 4 cannot run whole RAW queries

前端 未结 3 2169
再見小時候
再見小時候 2021-02-14 17:58

I would like to use the DB class of laravel to execute a mysql query but none of the functions provided by Laravel are working.

None of those is working: DB::statment()

3条回答
  •  情歌与酒
    2021-02-14 18:27

    Drop the users table from database then try this and let me know whether it works or not:

    DB::insert('CREATE TABLE `users` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `u_username` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
      `u_email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
      `password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
      `u_regdate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
      `u_birthday` date NOT NULL DEFAULT '0000-00-00',
      `u_lastlogin` int(11) NOT NULL,
      `u_logcout` int(11) NOT NULL DEFAULT '0',
      `u_level` tinyint(1) NOT NULL DEFAULT '0',
      `u_language` tinyint(1) NOT NULL DEFAULT '0',
      `u_status` tinyint(1) NOT NULL DEFAULT '0',
      `u_gender` tinyint(1) NOT NULL DEFAULT '0',
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci');
    
    //and so on for all the other queries.
    

提交回复
热议问题