PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $query = "create table users ( id INT AUTO_INCREMENT PRIMARY KEY, name varchar(100), phone varchar(20), created_at TIMESTAMP )"; // get DB version using PDO $stmt = $pdo->prepare($query); $stmt->execute(); foreach ($pdo->query("SHOW TABLES") as $row) { print_r( $row ); } $table = 'users'; $stmt = $pdo->prepare("describe ?"); $stmt->execute([$table]); $columns = $stmt->fetchAll(PDO::FETCH_ASSOC); print_r($columns); ////////////////// $name = "Jeong"; $phone = "080"; $table = 'users'; $stmt = $pdo->prepare("insert into ? (name. phone) values (? ,?) "); $stmt->execute([$table, $name, $phone]); echo "done";
Show:  
Copy Clear