Skip to content

Instantly share code, notes, and snippets.

@juanwilde
Created March 10, 2016 21:02
Show Gist options
  • Save juanwilde/f24bc86e7c67163b64b8 to your computer and use it in GitHub Desktop.
Save juanwilde/f24bc86e7c67163b64b8 to your computer and use it in GitHub Desktop.
Example
public function save($data)
{
$customer = new Customer();
$customer->setName($data['name']);
if (isset($data['lastname'])) $customer->setLastname($data['lastname']);
$customer->setPhone($data['phone']);
if (isset($data['address'])) $customer->setAddress($data['address']);
if (isset($data['email'])) $customer->setEmail($data['email']);
$customer->setEquipment($data['equipment']);
$customer->setPass($data['pass']);
$customer->setTasks($data['tasks']);
$customer->setStatus($data['status']);
$customer->setLocation($data['location']);
if (isset($data['notes'])) $customer->setNotes($data['notes']);
if (isset($data['price'])) $customer->setPrice($data['price']);
$customer->setInformed($data['informed']);
$this->em->persist($customer);
$this->em->flush();
// Get the last ID inserted and create controls
// for all admins
$lastInsertId = $customer->getId();
if ($lastInsertId) {
return $lastInsertId;
}
return false;
}
@kesar
Copy link

kesar commented Mar 10, 2016

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment