Support the ongoing development of Laravel.io →
posted 10 years ago
Database
Last updated 2 years ago.
0
Last updated 2 years ago.
0

Thanks for the link Zenry! Sorry to say that I still don't get it.

This is the script that I wanted to do. It works fine when not in laravel. What is the laravel way to do this?

$check = mysql_query("CREATE TABLE IF NOT EXISTS ".$testname." ( id INT, user VARCHAR(30), questn VARCHAR(30), ans VARCHAR(30))");

mysql_query ("INSERT IGNORE INTO ".$testname." SELECT * FROM test");

Last updated 2 years ago.
0
$db = DB::connection();

$sql = "CREATE TABLE IF NOT EXISTS ".$testname." ( id INT, user VARCHAR(30), questn VARCHAR(30), ans VARCHAR(30))";
$db->statement($sql);

$sql = "INSERT IGNORE INTO ".$testname." SELECT * FROM test";
$db->statement($sql);
Last updated 2 years ago.
0

Thank you very much Paulboco! It works!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

helmikuu27 helmikuu27 Joined 31 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.