public function GenericEntityManager(GenericEntity $entity)
 {
     $this->Updater = new Updater();
     if ($this->Updater->ExistEntry($entity)) {
         $this->entityToManage = $entity;
     } else {
         echo "entity not found.";
         die;
     }
     $this->PDO = ConnectionProvider::getConnection();
     $this->findAll .= Constants::$databaseName . "." . $entity->getTablename();
     $this->findById .= Constants::$databaseName . "." . $entity->getTablename() . " where " . $this->entityToManage->getIdcolumn() . " = '";
     $this->lastId .= Constants::$databaseName . "." . $entity->getTablename();
     $this->countAll .= Constants::$databaseName . "." . $entity->getTablename();
 }
Пример #2
0
 public function Updater()
 {
     $this->PDO = ConnectionProvider::getConnection();
     $this->GenericEntityManager = new GenericEntityManager();
 }
Пример #3
0
 public function readAll()
 {
     $sql = "select * from comment where post_id='" . $_REQUEST['post_id'] . "' order by created desc;";
     $comments = array();
     foreach (ConnectionProvider::getConnection()->query($sql) as $row) {
         $comment = new Comment();
         $comment->id = $row['id'];
         $comment->text = $row['text'];
         $comment->post_id = $row['post_id'];
         $comment->created = $row['created'];
         $comment->author_name = $row['author_name'];
         $comments[] = $comment;
     }
     return $comments;
 }