Example #1
0
 /**
  * Updates the current entry in the database
  */
 public function update()
 {
     /* @var $statement \PDOStatement */
     $this->setDateModified();
     $query = "UPDATE {$this->_table} SET {$this->_updateString} WHERE {$this->_primaryKey} = " . (int) $this->getPrimaryKey();
     $statement = $this->_pdo->prepare($query);
     $fields = $this->_descriptionManager->getTableDescription();
     foreach ($fields as $field => $type) {
         $value = $this->{$field};
         if (is_null($value) && $type->Null == 'NO') {
             $value = self::notNullDefault($type->Type);
         }
         $statement->bindValue(":{$field}", $value, Database::mySqlTypeToPdoType($type->Type));
     }
     $statement->execute();
 }