I'm trying to wrap my head around PDO. How come $lastid doesn't output anything?
function renderRoot($db){
$sql = "INSERT INTO nodes (name) VALUES ('/');";
$response = $db->query($sql);
$lastid = $db->lastInsertId();
echo $lastid;
return;
}
The code adds a value to the table and it has an column called id, that aoutincrements.
Here is my sql(postgresql):
$nodetable = "create table nodes (
id serial primary key,
parentid integer references nodes(id ),
name varchar
);";