Skip to content

Commit

Permalink
skip DirectoryIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Dec 20, 2019
1 parent 8794794 commit c56d8d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion s/create.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use PUGX\Shortid\Factory;
use PUGX\Shortid\Shortid;

$pdo = new PDO('mysql:host=localhost;dbname='.MYSQL_DATABASE, MYSQL_USERNAME, MYSQL_PASSWORD);
Expand All @@ -20,7 +21,10 @@
if ($result !== false) {
echo json_encode($result);
} else {
$id = Shortid::generate(10);
$factory = new Factory();
$factory->setLength(10);
Shortid::setFactory($factory);
$id = Shortid::generate();
$prepare = $pdo->prepare('INSERT INTO short_url (uniqId, keyword) VALUES (:id, :keyword)');
$prepare->execute([':id' => $id, ':keyword' => $keyword]);
echo json_encode(['uniqId' => $id, 'keyword' => $keyword]);
Expand Down

0 comments on commit c56d8d5

Please sign in to comment.