Mkdir()

I have a mysql table and am trying to make a directory for each record. The PK for each record id 1, 2, 3, 4… and want to make the directory the same (1,2,3,.4…) so that it’dd be obvious which directory belongs to which record.
I am trying to use the mkdir() thing to create the directory as soon as the new record is created.


try { 
$sql = "INSERT INTO `providers` (  `name`,  `email`,  `phone`,  `c_method`,  `rate`,  `age`,  `r_count`,  `introduction`,  `thumb`,  `created`,  `display`  ) VALUES (  :name,  :email,  :phone,  :c_method,  :rate,  :age,  :r_count,  :intro,  :thumb,  :date_created,  :display)"; 
$stmt = $dbh->prepare($sql);
 $stmt->execute(array(    ':name' => $name,    ':email' => $email,    ':phone' => $phone,    ':c_method' => $c_method,    ':rate' => $rate,    ':age' => $age,    ':r_count' => $r_count,    ':intro' => $intro,    ':thumb' => $thumb,    ':display' => $display,    ':date_created' => $date_created  ))
;//now that the query has run and 1 record is added, lets create the directory
mkdir("../providers/"/*how do I get the above PK here?*/):

Thanks…

You can make use of PDO’s lastInsertId() method to retrieve the ID of the last inserted row. From there, simply add that onto the string of the argument for mkdir(). The following should work:


mkdir("../providers/{$dbh->lastInsertId()}");

thanks