Example #1
0
 public function save(Zadanie $zadanie)
 {
     $zadanieData = array('nazov' => $zadanie->getNazov(), 'trieda_id' => $zadanie->getTriedaId(), 'pouzivatel_id' => $zadanie->getPouzivatelId(), 'predmet_id' => $zadanie->getPredmetId(), 'stav' => $zadanie->getStav(), 'cas_uzatvorenia' => $zadanie->getCasUzatvorenia());
     if ($zadanie->getId()) {
         $this->db->update('zadania', $zadanieData, array('zadanie_id' => $zadanie->getId()));
     } else {
         $this->db->insert('zadania', $zadanieData, array(PDO::PARAM_STR, PDO::PARAM_INT, PDO::PARAM_INT, PDO::PARAM_INT, PDO::PARAM_INT, 'datetime'));
         $id = $this->db->lastInsertId();
         $zadanie->setId($id);
     }
 }
 private function getRevisionId()
 {
     if ($this->revisionId === null) {
         $date = date_create("now")->format($this->platform->getDateTimeFormatString());
         if ($this->config->getCurrentUser() != null) {
             $userId = $this->config->getCurrentUser()->getId();
         } else {
             $userId = null;
         }
         $this->conn->insert($this->config->getRevisionTableName(), array('timestamp' => $date, 'user_id' => $userId, 'note' => $this->config->getNote(), 'ipaddress' => $this->config->getIpAddress()));
         $sequenceName = $this->platform->supportsSequences() ? 'REVISIONS_ID_SEQ' : null;
         $this->revisionId = $this->conn->lastInsertId($sequenceName);
     }
     return $this->revisionId;
 }
Example #3
0
 /**
  * Creates a new entry in the table
  * @return $this
  */
 public function create()
 {
     reset($this->__fields);
     $pk = key($this->__fields);
     $form = $this->getForm();
     $placeholders = array();
     foreach ($form as $k => $v) {
         $placeholders[$k] = ':' . $k;
     }
     $sql = sprintf('INSERT INTO %s (%s) VALUES (%s)', $this->getTableName(), implode(',', array_keys($placeholders)), implode(',', $placeholders));
     $stmt = $this->__db->prepare($sql);
     foreach ($form as $k => $v) {
         if (is_object($v->getData()) && get_class($v->getData()) == 'DateTime') {
             $stmt->bindValue($k, $v->getData(), $this->__fields[$k]['type']);
         } else {
             $stmt->bindValue($k, $v->getData());
         }
     }
     $stmt->execute();
     $this->{$pk} = $this->__db->lastInsertId();
     return $this;
 }