How can i remove "dato" from $this->v ? And still have it in the $sql string.
OUTPUT (var_dump($this->v)):
array (size=4) ':kategori' => string 'Youstube' (length=8) ':link' => string 'http://urls' (length=11) ':navn' => string 'Rss feeds' (length=9) ':dato' => string 'NOW()' (length=5) OUTPUT (echo $sql)
UPDATE rss_kategori SET kategori = :kategori, link = :link, navn = :navn, dato = NOW()
CODE:
$classVars = get_class_vars(get_class($this)); $sql .= "UPDATE {$this->table} SET "; foreach ($classVars as $key => $value) { if ($key == 'v' || $key == 'db' || $key == 'id' || $key == 'table' || $key == 'table_id') { continue; } $keys = ""; $values = ""; $keys .= $key; if ($this->$key == 'NOW()') { $values .= $this->$key . ","; } else { $values .= ":" . $key . ","; } $this->v[":" . $key] = $this->$key; $sql .= "{$keys} = " . $values . " "; } $sql = substr($sql, 0, -2) . " WHERE {$this->table_id} = '{$this->id}'";
unset. see here stackoverflow.com/questions/369602/…