Skip to content

Instantly share code, notes, and snippets.

@jlebrech
Created February 3, 2011 11:05
Show Gist options
  • Save jlebrech/809354 to your computer and use it in GitHub Desktop.
Save jlebrech/809354 to your computer and use it in GitHub Desktop.
in the model
<?php
function save($id=null)
{
$this->title = $this->input->post('title');
$this->code = $this->input->post('code');
$this->permalink = $this->input->post('permalink');
if ($this->input->post("id")){ // is there an id
$this->modified = date('Y-m-d H:i:s'); // then it's modified
$this->db->update('pages',$this, array('id'=>$this->input->post('id')));
} else {
$this->created = date('Y-m-d H:i:s'); // then it's created
$this->modifed = $this->created;
$this->db->insert('pages',$this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment