Hello all
I am using Zend Framework.
I would like to insert array $color = array('red', 'blue', 'green', 'yellow');
into mysql, one color to one row.
How do I code this in my model file?
Controller
public function addAction()
{
$this->view->Title = "Add Colors";
$this->view->headTitle($this->view->title, 'PREPEND');
$form = new Form_Color();
$form->submit->setLabel('Add');
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
$color = $form->getValue('color');
$colors = new Model_DbTable_Colors();
$colors->addColor($color);
$this->_redirect('/');
} else {
$form->populate($formData);
}
}
}
Model
public function addColor($color)
{
$data = explode("\n",$color);
// How to coding for insert one color one row ????
}
thank you for your time.