I would like to know how to write this query in pdo
Here I want to copy the structure of old_table to new_table. I know to create table in PDO. I want to know how to write below mentioned query in PDO.
query : CREATE TABLE new_table LIKE old_table;
actual code I used:
$tempname=1001; //(its user registration id)
$keyword='temp_quesion%'; //(temp_question table already exists in db)
$conn = new PDO('mysql:host='. DB_HOST .';dbname='. DB_NAME . ';charset=utf8', DB_USER, DB_PASS);
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );//Error Handling
$sql =$conn->prepare("CREATE TABLE ".$tempname."_temp_question LIKE :refer ");
$sql->bindParam(':refer', $keyword);
$sql->execute();
Here I want create temporary table to every user who login.