Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

insert into sql in pdo

<?php

$pdo = require_once 'connect.php';

// insert a single publisher
$name = 'Macmillan';
$sql = 'INSERT INTO publishers(name) VALUES(:name)';

$statement = $pdo->prepare($sql);

$statement->execute([
	':name' => $name
]);

$publisher_id = $pdo->lastInsertId();

echo 'The publisher id ' . $publisher_id . ' was inserted';
Source by www.phptutorial.net #
 
PREVIOUS NEXT
Tagged: #insert #sql #pdo
ADD COMMENT
Topic
Name
7+3 =