/** * @covers Zend\Db\TableGateway\AbstractTableGateway::__get */ public function test__get() { $this->table->insert(array('foo')); // trigger last insert id update $this->assertEquals(10, $this->table->lastInsertValue); $this->assertSame($this->mockAdapter, $this->table->adapter); //$this->assertEquals('foo', $this->table->table); }
public function insert($set) { $set['photo'] = $set['photo']['tmp_name']; unset($set['password_verify']); $set['password'] = md5($set['password']); // better than clear text //passwords return parent::insert($set); }
public function insertItem(array $data) { $this->OrderItemTableGateway->insert($data); return $this->OrderItemTableGateway->getLastInsertValue(); }
/** * Insert new row to database * * @param mixed $object * @return int * @throws \Exception\BadMethodCallException */ public function insert($object) { if (is_array($object)) { return parent::insert($object); } if (!is_callable(array($object, 'getArrayCopy'))) { throw new \BadMethodCallException(sprintf('%s expects the provided object to implement getArrayCopy()', __METHOD__)); } $preInsertMethodName = $this->eventActions[self::PRE_INSERT]; $postInsertMethodName = $this->eventActions[self::POST_INSERT]; if (method_exists($object, $preInsertMethodName)) { $object->{$preInsertMethodName}($this->getEventManager()); } $set = $object->getArrayCopy(); if (isset($set[$this->keyName])) { unset($set[$this->keyName]); } $res = parent::insert($set); if (method_exists($object, $postInsertMethodName)) { $object->{$postInsertMethodName}($this->getEventManager()); } return $res; }
/** * Insert l'objet en base. * * @param mixed $mObject * @return int * @throws \Exception\BadMethodCallException */ public function insert($mObject) { if (is_array($mObject)) { return parent::insert($mObject); } if (!is_callable(array($mObject, 'getArrayCopy'))) { throw new \BadMethodCallException(sprintf('%s attend que l\'objet fournit implémente la méthode getArrayCopy()', __METHOD__)); } $preInsertMethodName = $this->eventActions[self::PRE_INSERT]; $postInsertMethodName = $this->eventActions[self::POST_INSERT]; if (method_exists($mObject, $preInsertMethodName)) { $mObject->{$preInsertMethodName}($this->getEventManager()); } $set = $mObject->getArrayCopy(); $res = parent::insert($set); if (method_exists($mObject, $postInsertMethodName)) { $mObject->{$postInsertMethodName}($this->getEventManager()); } return $res; }
public function create($data) { $hydrator = new ObjectProperty(); $data = $hydrator->extract($data); return $this->tableGateway->insert($data); }
public function fetchAll() { $rowset = $this->select(); $data = array(); foreach ($rowset as $row) { $data[] = $row; } return $data; } public function updateRecord($id, $data) { $ret = $this->update($data, array($this->pk => $id)); if ($ret <= 0) { throw new CommonException(array('messageId' => 'globals.query.record_not_found', 'parms' => array('id' => $id), EXCEPTION_ERRORKEY => 404)); } $ret = array('rowcount' => $ret); return $ret; } public function insertRecord($data) { try { parent::insert($data); // If the entity has a sequence on the PK then I am going to try // and retrieve that generated value to send it back if ($this->hasSequence()) { $ret = $this->getLastInsertValue(); if ($ret <= 0) { throw new CommonException(array('messageId' => 'globals.query.record_not_created', 'parms' => array('id' => implode(' - ', $data)), EXCEPTION_ERRORKEY => 500)); } } else { // No sequence, then I send back the PK value // If PK value does not exist, then I will send 1 $ret = isset($data[$this->pk]) ? $data[$this->pk] : 1; } return $ret; } catch (CommonException $ce) {
public function updateItem(array $data) { $this->orderItemTableGateway->insert($data); $id = $this->orderItemTableGateway->getLastInsertValue(); return $id; }
public function insert($client) { $this->tableGateway->insert((array) $client); return $this->tableGateway->getLastInsertValue(); }
/** *insert * * Wrapper for 'insert'. * --------------------- *Handle the insertion of model objects in addition to the traditional stuff you could pass into TableGateway's insert. * * * * * * @param array|object $set * *@return int * * * */ public function insert($set) { if (is_object($set)) { return parent::insert($set->toArray()); } else { return parent::insert($set); } }