<?php
// pdo: preprocessing
// The essence of preprocessing: the data in the sql statement is dynamically bound
// Dynamic binding: real data is bound only when sql is executed
// Static binding: data is written directly to sql
// 1. Static: select * from staff where id > 10
// 2. Dynamic (preprocessing): select * from staff where id > ?
##// 1. Anonymous parameter index arraynamespace pdo_edu;use PDO;// Connection$db = new PDO('mysql:dbname=bittel', 'root', 'root');// CURD: INSERT// Anonymous parameters: ?$sql = 'INSERT `staff` SET `name`= ?,`sex`= ?,`email`= ?;'; // sql statement->sql statement template object->preprocessing object$stmt = $db->prepare($sql);/ / Placeholder in sql statement?, bind real data to it// Index array$data = ['Yangguo', 0, 'yangguo@qq.com'] ;//Execute sql$stmt->execute($data);// Verification: Print sql preprocessing command// $stmt->debugDumpParams();echo 'Added successfully, id = ' . $db->lastInsertId () . '<br>';
This is my field type, you can insert it normally using your code
What error was reported?