<?php namespace SQL3; require_once 'Comment.php'; require_once '../PDOWrapper.php'; use PDOWrapper; $dbWrapper = new PDOWrapper(); $connection = $dbWrapper->getConnection(); $forumIds = array(); foreach ($connection->query('SELECT id FROM forum') as $row) { $forumIds[] = $row['id']; } $loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."; $comment = new Comment($connection); $comment->setAuthor('Author' . rand(0, 10)); $comment->setForumId($forumIds[rand(0, sizeof($forumIds) - 1)]); $comment->setString($loremIpsum . rand(0, 1000)); $comment->save(); echo "<div>" . $comment->getForumId() . "</div>"; echo "<div>" . $comment->getAuthor() . "</div>"; echo "<div>" . $comment->getString() . "</div>";
<?php namespace SQL3; require_once 'Comment.php'; require_once '../PDOWrapper.php'; require_once "CommentRepository.php"; require_once "ForumRepository.php"; use PDOWrapper; $commentrep = new CommentRepository(); $forumrep = new forumRepository(); $loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."; $comment = new Comment(); $comment->setAuthor('Author' . rand(0, 1000)); $comment->setForumID($forumrep->getRandomId()); $comment->setString($loremIpsum . rand(0, 1000)); $commentrep->saveComment($comment); echo "<div>" . $comment->getforumID() . "</div>"; echo "<div>" . $comment->getAuthor() . "</div>"; echo "<div>" . $comment->getString() . "</div>";