PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table contacts ( id int primary key auto_increment, name varchar(255) unique key );
Copy Clear
Copy Format Clear
<?php $name = 'test'; try { $stmt = $pdo->prepare(" INSERT INTO contacts(name) VALUES (:name)"); $stmt->bindValue(":name", $name); return $stmt->execute(); } catch (PDOException $Exception) { print_r($Exception); } $query = "SELECT * FROM contacts;"; $stmt = $pdo->prepare($query); $stmt->execute(); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); var_export($rows);
Show:  
Copy Clear