/** * {@inheritDoc} */ public function save(ModelInterface $objItem) { $arrSet = array(); foreach ($objItem as $key => $value) { if ($key == 'id') { continue; } if (is_array($value)) { $arrSet[$key] = serialize($value); } else { $arrSet[$key] = $value; } } if ($this->timeStampProperty) { $arrSet[$this->getTimeStampProperty()] = time(); } if ($objItem->getID() == null || $objItem->getID() == '') { $objInsert = $this->objDatabase->prepare(sprintf('INSERT INTO %s %%s', $this->strSource))->set($arrSet)->execute(); if (strlen($objInsert->insertId) != 0) { $objItem->setID($objInsert->insertId); } } else { $this->objDatabase->prepare(sprintf('UPDATE %s %%s WHERE id=?', $this->strSource))->set($arrSet)->execute($objItem->getID()); } return $objItem; }