public function deleteItemsNotInArray($id, $itemsIds)
 {
     $where = new Where();
     $where->equalTo('order_id', $id);
     $where->notIn('id', $itemsIds);
     $this->tableGatewayItems->delete($where);
 }
 /**
  * @covers Zend\Db\TableGateway\AbstractTableGateway::delete
  * @covers Zend\Db\TableGateway\AbstractTableGateway::deleteWith
  * @covers Zend\Db\TableGateway\AbstractTableGateway::executeDelete
  */
 public function testDelete()
 {
     $mockDelete = $this->mockSql->delete();
     // assert select::from() is called
     $mockDelete->expects($this->once())->method('where')->with($this->equalTo('foo'));
     $affectedRows = $this->table->delete('foo');
     $this->assertEquals(5, $affectedRows);
 }
 public function delete($id)
 {
     $items = $this->orderItemTableGateway->select(['order_id' => (int) $id]);
     foreach ($items as $item) {
         $this->orderItemTableGateway->delete(['id' => $item->getId()]);
     }
     return $this->tableGateway->delete(['id' => (int) $id]);
 }
 public function delete($id)
 {
     $this->TableGateway->delete(['id' => (int) $id]);
     return true;
 }
 /**
  * Delete object from database
  *
  * @param mixed $objectOrWhere
  */
 public function delete($objectOrWhere)
 {
     $isEntityObjectDelete = $objectOrWhere instanceof \VisioCrudModeler\Model\TableGateway\Entity\AbstractEntity;
     if ($isEntityObjectDelete) {
         $object = $objectOrWhere;
         $id = is_array($object) ? $object[$this->keyName] : $object->{$this->keyName};
         $where = array($this->keyName => $id);
     } else {
         $where = $objectOrWhere;
     }
     $preDeleteMethodName = $this->eventActions[self::PRE_DELETE];
     $postDeleteMethodName = $this->eventActions[self::POST_DELETE];
     if ($isEntityObjectDelete && method_exists($object, $preDeleteMethodName)) {
         $object->{$preDeleteMethodName}($this->getEventManager());
     }
     parent::delete($where);
     if ($isEntityObjectDelete && method_exists($object, $postDeleteMethodName)) {
         $object->{$postDeleteMethodName}($this->getEventManager());
     }
 }
 public function delete($id)
 {
     return parent::delete(array($this->primaryKeyField => $id));
 }
Exemplo n.º 7
0
 /**
  *  Supprime un objet en base.
  *
  * @param mixed $mObjectOuWhere
  */
 public function delete($mObjectOuWhere)
 {
     $isEntityObjectDelete = $mObjectOuWhere instanceof \Core\Model\AbstractModel;
     if ($isEntityObjectDelete) {
         $object = $mObjectOuWhere;
         $id = is_array($object) ? $object[$this->nomCle] : $object->{$this->nomCle};
         $where = array($this->nomCle => $id);
     } else {
         $where = $mObjectOuWhere;
     }
     $preDeleteMethodName = $this->eventActions[self::PRE_DELETE];
     $postDeleteMethodName = $this->eventActions[self::POST_DELETE];
     if ($isEntityObjectDelete && method_exists($object, $preDeleteMethodName)) {
         $object->{$preDeleteMethodName}($this->getEventManager());
     }
     parent::delete($where);
     if ($isEntityObjectDelete && method_exists($object, $postDeleteMethodName)) {
         $object->{$postDeleteMethodName}($this->getEventManager());
     }
 }
Exemplo n.º 8
0
 public function delete($id)
 {
     return parent::delete(array($this->pk => $id));
 }