Last week we need a decision to use either Zend3 or CI3. In order to test it I used the Zend3 skeleton module which is a simple CRUD project.
here my edit function from the controller
Code:
public function edit($id = NULL)
{
$data['title'] = "My Album";
//get the album data
$data['album'] = $this->albums_model->getByID($id);
$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('artist', 'Artist', 'required');
if ($this->form_validation->run() == FALSE)
{
//show the form when not valid
$this->load->view( get_class($this) . '/add', $data);
}
else
{
//add the data
$data = array(
'title' => $this->input->post('title'),
'artist' => $this->input->post('artist')
);
$this->db->where('id', $id);
$this->db->update('album', $data);
redirect('/albums/');
}
}
And here the function from the model
Code:
public function getByID($id)
{
$query = $this->db->get_where('album', array('id' => $id));
if ( $query->num_rows() > 0){
return $query->row();
} else {
return false;
}
}
This is all very simple but hope it helps.
(We did decide to use CI3 rather then Zend)
On the package it said needs Windows 7 or better. So I installed Linux.